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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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