I am playing the music from a function called intro.
This function is run in the update loop.
When the game state is intro then intro is showed and this is the moment I'd like to hear some music.
Problem is that the intro function is called every time the update loop restarts and therefore the music restarts everytime producing a choppy noise.
How can I solve this issue?
My code is available here:
Thanks for your time and help :)
something like that?
function togglemusic(n) if (music_playing) then music(-1) music_playing=false else music(n) music_playing=true end end
also I think there are peeks and pokes for the music whereabouts but I never looked into that.
edit: oups, sorry, not what you asked for.
this should do:
function startmusic(n) if (not music_playing) then music(n) music_playing=true end end function stopmusic() music(-1) music_playing=false end
call startmusic() in intro()
[Please log in to post a comment]