Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Audio loop not stopping, phaser


craidencool
 Share

Recommended Posts

//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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...