Jump to content

Pause and Sound resume issue


jclyra
 Share

Recommended Posts

Hi,

I'm really new to phaser and having some issues with my game on which I created a script that when the player clicks or goes outside of the game (e.g. clicks another tab), the music should be paused and when it resumes (user clicks back in game), music should continue. The issue is that when the game continues, it music starts over the very beginning. I've followed some of the examples that I've found here but still does not work. Anyone experiencing the same thing or it's juts with my implementation?

 

var introState = function(game){
};

introState.prototype = {

    preload: function(){
        game.load.audio('intro', '../music/intro.mp3');
    },
    create: function(){
        recording = game.add.audio('intro');
        recording.play();

        game.onPause.add(pauseMusic, this);
        game.onResume.add(resumeMusic, this);

    },
    render: function(){
    }
}

function pauseMusic() {
    recording.pause();
}

function resumeMusic() {
    recording.resume();
}

 

This is just one of a state with in my game. Any help is appreciated.

Thanks

Link to comment
Share on other sites

Hey,

Appreciate your Alex reply. But something is really weird. I tested the code here at home and it works perfectly fine. Maybe this is a browser issue. I will try to compare my browser here at home and at the office.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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