Hello !
I have been toying around with background music and such and I have an issue, that I can’t seem to fix: I have different scenes in the game, a main menu, a sub-menu and a game scene. All the background music plays fine the first time, but when I finish the game and I get back to the main menu, the music does not start again.
I create the background music for the menu and the sub menu with this code:
function scene:createScene( event ) local screenGroup = self.view backgroundMusic = audio.loadStream("music/menu.mp3")
and I play it in the enterScene part
function scene:enterScene( event ) ... backgroundMusicChannel = audio.play( backgroundMusic, {channel=1,loops=-1 } )
It works fine until I finish the game and get back to the main menu, which it should start playing again.
The funny thing is it seems to work okay if I remove the audio options ( it only plays once ).
To change the background music I use the following code:
audio.fadeOut({ channel=1, time=2500 } )
Before changing the scene and starting playing (inside the game class) the next song.
Channel 1 is reserved and it seems that channel 1 state never fully stops.
I’ve tried printing some audio properties on the console prompt :
print (audio.isChannelActive( backgroundMusicChannel )) print (audio.isChannelPaused( backgroundMusicChannel )) print (audio.isChannelPlaying( backgroundMusicChannel ))
And it returns :
true false true
For the first and the other iterations if I don’t go back from the submenu to the menu, I mean if I go from the main menu to the submenu and then I play and after playing I get back to the main menu. Otherwise, if I get back from the submenu I get the values
false false false
Anyone has any tips about what can I be doing wrong?
Thanks!
And I was planning in using the GGSound utility for my next game n_n but maybe I change everything and start using it now.