Love bgmusic
Posted: Tue Mar 23, 2010 3:48 am
I'm trying to make any sensible way of playing background music with the option of letting the user stop it in-game.
This above works fine for me. If I press "m" then the music starts, and it is fantastic.
However if I make any attempt to have a function available to stop the bgmusic, it will no longer start. For example if I simply add:
then I will only hear the first one second of the audio when I press "m." I am not pushing "n."
There is no other change being made to the code. The audio source is a .ogg and is set to "stream."
I do not understand why a condition that hasn't been met has some effect on the rest of the program.
Maybe there is a better function to manage by audio activity?
Code: Select all
if key == "m" then
love.audio.play(bgmusic)
end
However if I make any attempt to have a function available to stop the bgmusic, it will no longer start. For example if I simply add:
Code: Select all
if key == "n" then
love.audio.stop()
end
There is no other change being made to the code. The audio source is a .ogg and is set to "stream."
I do not understand why a condition that hasn't been met has some effect on the rest of the program.
Maybe there is a better function to manage by audio activity?