QLNEO Posted August 24, 2017 Share Posted August 24, 2017 All I need is to stop all sound playback before I load another state. I have this music playing at the menu, and I'm having trouble when transitioning into the main game. It goes as follows: music intro and music loop are separated files; intro plays once, and its onStop event has a listener that plays the loop (on loop, of course). If I do nothing, when state changes, the playback won't stop (even though clearWorld parameter is true), and it'll attempt to loop as well. If I use game.sound.destroy() before starting the new state, "An attempt was made to use an object that is not, or is no longer, usable". Maybe it has to do with the fact that I'm using, as a placeholder, the menu music in the main game, but fact is, even if I load the audio file again in preload(), it just doesn't let me play and crashes. :/ Link to comment Share on other sites More sharing options...
samme Posted August 24, 2017 Share Posted August 24, 2017 Have you called stop() on all the sounds? Link to comment Share on other sites More sharing options...
samme Posted August 24, 2017 Share Posted August 24, 2017 Or game.sound.stopAll(); Titus 1 Link to comment Share on other sites More sharing options...
QLNEO Posted August 25, 2017 Author Share Posted August 25, 2017 Yeah, that was the ticket. Embarassingly enough, that even crossed my mind, but I was afraid that it would mess up with the onStop listener I set to the intro, but I knew I could just remove the listener before. By then that simple thought already went away and I tried going with removeAll() instead. Thanks again Link to comment Share on other sites More sharing options...
Recommended Posts