craidencool Posted July 10, 2016 Share Posted July 10, 2016 //CREATE back_music = this.game.add.audio('back_music'); back_music.play('', 0,1,true); //FUNCTION TO SWITCH STATE this.game.state.start('Menu'); select_audio.play(); back_music.stop(); Hey guys! I am having a problem with my game audio. If I switch states and my game is not looped the audio would stop as I intended it to do. but when the audio loop once or twice and I switch states the audio keeps playing. Hope you can help me with this one. thank you! This is the code that I am using. Link to comment Share on other sites More sharing options...
3ddy Posted July 11, 2016 Share Posted July 11, 2016 If your back_music is global, then you can use if (back_music && back_music.isPlaying){back_music.stop(); } at the beginning of new state - it will just stop the music if it is still playing Link to comment Share on other sites More sharing options...
Recommended Posts