Jump to content

How to unpause


JamieR
 Share

Recommended Posts

5 hours ago, samme said:

How exactly are you pausing the game?

As long as the game still has focus, input updates are still run (except gamepads, on earlier Phaser). You can verify with the debug input/pointer methods. 

 

Hi - thanks for the reply.

So far, being a complete amateur, I have only been using this.game.paused = true; which does achieve the pausing but without the ability to unpause - not sure if this is the best way or not. I am using the Kore Springs version as the tutorial I am following is based on that - would that be the issue?

Link to comment
Share on other sites

So - I have two buttons - one for pausing the other for unpausing

pauseButton = this.game.add.button(this.game.world.centerX, 500, 'restartButtonimg', pauseButtonAciononClick, this, 2, 1, 0);
pauseButton.anchor.setTo(0.5, 0.5)
unpauseButton = this.game.add.button(this.game.world.centerX, 300, 'restartButtonimg', unpauseButtonAciononClick, this, 2, 1, 0);

When clicked, they call -

function pauseButtonAciononClick () { 
  this.game.paused = true;
}
function unpauseButtonAciononClick () { 
  this.game.paused = false;

}

The pause button works fine in that the game is paused. However, the unpause does not work in that it doesn't unpause, but I coded it to do a console.log which it did do, so I am unsure what is wrong? It seems that the button for unpause does not respond, as I guess input is paused, but if you are saying that it shouldn't disrupt the update process then I'm unsure how to fix it?

Using Kore Springs.

Thanks

image.gif

image.gif

Link to comment
Share on other sites

Are you running in an iframe? it sounds similar to https://github.com/photonstorm/phaser-ce/issues/236 but I'm not sure.

6 hours ago, JamieR said:

The pause button works fine in that the game is paused. However, the unpause does not work in that it doesn't unpause, but I coded it to do a console.log which it did do, so I am unsure what is wrong?

If the button is successfully doing console.log then it's very strange that it isn't unpausing the game as well.

Have you checked the value of game.paused after clicking the button? And what exactly happens? I assumed you see that all your game objects are frozen. Do you mean something else, like the game stops getting pointer or keyboard events?

Can you try: 

game.onBlur.add(function () {
  console.log('game.onBlur');
  console.trace();
});

game.onFocus.add(function () {
  console.log('game.onFocus');
  console.trace();
});

game.onPause.add(function () {
  console.log('game.onPause');
  console.trace();
});

game.onResume.add(function () {
  console.log('game.onResume');
  console.trace();
});

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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