Jump to content

Can't seem to stop looping music


bluedot
 Share

Recommended Posts

Hi,

 

I'm having problems stopping music once started:

 

I'm using this code:

 

preload:

 

        this.game.load.audio('backgroundMusic', 'assets/oedipus_ark_pandora.mp3');
 
create:
 
        this.backgroundMusic = this.game.add.audio('backgroundMusic');
        this.backgroundMusic.volume = 0.3;
        this.backgroundMusic.loop = true;
        this.backgroundMusic.play();
 
displayResults:
 
        this.backgroundMusic.loop = false;
        this.backgroundMusic.stop();
        this.state.start('Results');
 

 

The problem is the music keeps playing when the state switched. Is this a bug or am I doing something wrong ? It seems to work if there's no looping set.

 

Thanks.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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