having an issue where I can't stop the music from looping
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 6
- Joined: Fri May 11, 2012 2:35 am
having an issue where I can't stop the music from looping
function love.load()
opening = love.audio.newSource("horror017.mp3" ,"static")
reddeath = love.graphics.newImage("RedMoon.jpg")
X = 0
y = 0
end
function love.draw()
love.graphics.draw(reddeath, x,y)
love.graphics.print("Loading Death", 700,580)
opening:setPitch(0.7)
opening:setLooping(false)
love.audio.play(opening)
end
however do to the nature of the .draw information it would contently repeat after it finished playing the sound clip i found that if i reworte the program as such:
function love.load()
opening = love.audio.newSource("horror017.mp3" ,"static")
reddeath = love.graphics.newImage("RedMoon.jpg")
X = 0
y = 0
opening:setPitch(0.7)
opening:setLooping(false)
love.audio.play(opening)
end
function love.draw()
love.graphics.draw(reddeath, x,y)
love.graphics.print("Loading Death", 700,580)
end
it would work however telling it that looping was false was now pointless considering that .load only runs once anyways Im wondering if im useing the wrong function type or that i did something else wrong with the setLooping(false) information please let me know if this is the only way of doing it or if im doing something else wrong I would love to know so I can learn from it
Re: having an issue where I can't stop the music from loopin
You can put that snippet in the code tags, for easier viewing. And instead of write . Do this in the love.load().
Code: Select all
setLooping
Code: Select all
isLooping
Losing a friend's trust is the fastest way to lose a friend, forever. FOREVER!
-
- Prole
- Posts: 6
- Joined: Fri May 11, 2012 2:35 am
Re: having an issue where I can't stop the music from loopin
First thx for the tip for the forum. Second when I change the:
to
I still had the same problem where I had to put the audio.play in the love.load to prevent the sound clip from looping. I feel there should be another way to do this, but if there's not thx again for trying to help a newbie like me
Code: Select all
setLooping
Code: Select all
isLooping
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: having an issue where I can't stop the music from loopin
You do need setLooping, instead of isLooping, contrary to what jradich told you.
However, you call love.audio.play every single frame, hence it will always restart.
However, you call love.audio.play every single frame, hence it will always restart.
-
- Prole
- Posts: 6
- Joined: Fri May 11, 2012 2:35 am
Re: having an issue where I can't stop the music from loopin
Right so does that mean there's another callback function I need to put it in or is just love.load
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: having an issue where I can't stop the music from loopin
Just load your source, set the looping and start playing it inside love.load callback.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: having an issue where I can't stop the music from loopin
Or, find an event, or filter one, that doesn't get called as often. Maybe only start music once they click 'Start game' in the menu, or something like that.
-
- Prole
- Posts: 6
- Joined: Fri May 11, 2012 2:35 am
Re: having an issue where I can't stop the music from loopin
Well thx for the info i just wanted to know if there was another way in case i needed to do something like this later but for the current situation i think putting in the .load will be the easiest thing thx for all the help and advice though
Who is online
Users browsing this forum: Bing [Bot] and 3 guests