Page 1 of 1

Love bgmusic

Posted: Tue Mar 23, 2010 3:48 am
by adrywalsh
I'm trying to make any sensible way of playing background music with the option of letting the user stop it in-game.

Code: Select all

if key == "m" then
    love.audio.play(bgmusic)
end
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:

Code: Select all

if key == "n" then
    love.audio.stop()
end
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?

Re: Love bgmusic

Posted: Tue Mar 23, 2010 4:22 am
by adrywalsh
Another fun fact:
If I do not press "m" before another sound occurs, the music will not start.