JamieR Posted February 22, 2018 Share Posted February 22, 2018 Hi, I have set up the pausing function of my game, but it seems to be disabling all input when it is set to true. How do I fix this? Link to comment Share on other sites More sharing options...
casey Posted February 22, 2018 Share Posted February 22, 2018 I had a similar problem. The example @samme posted on my thread might help you. In the end, I found I had to use CANVAS mode to get input on pause. Link to comment Share on other sites More sharing options...
samme Posted February 22, 2018 Share Posted February 22, 2018 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. Link to comment Share on other sites More sharing options...
JamieR Posted February 22, 2018 Author Share Posted February 22, 2018 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 More sharing options...
samme Posted February 23, 2018 Share Posted February 23, 2018 That's the right way. game.paused = true; // … game.paused = false; Are you using a button or a click to unpause? I think that should still work. In my pen, the mouse/pointer coordinates and up/down state still get updated while the game is paused. And here's a pause/unpause button: misc/pause menu. Link to comment Share on other sites More sharing options...
JamieR Posted February 26, 2018 Author Share Posted February 26, 2018 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 Link to comment Share on other sites More sharing options...
samme Posted February 26, 2018 Share Posted February 26, 2018 What browser and input method (e.g., mouse) are you using? Link to comment Share on other sites More sharing options...
JamieR Posted February 26, 2018 Author Share Posted February 26, 2018 1 hour ago, samme said: What browser and input method (e.g., mouse) are you using? Chrome (most recent version) and mouse Link to comment Share on other sites More sharing options...
samme Posted February 26, 2018 Share Posted February 26, 2018 Do you think you could post an example? https://codepen.io/pen?template=vyKJvw Link to comment Share on other sites More sharing options...
JamieR Posted February 26, 2018 Author Share Posted February 26, 2018 24 minutes ago, samme said: Do you think you could post an example? https://codepen.io/pen?template=vyKJvw It appears to be working on there. I wonder if I should attempt to upgrade my version of Phaser and hope it doesn't break!? Link to comment Share on other sites More sharing options...
JamieR Posted February 26, 2018 Author Share Posted February 26, 2018 Is there any way of achieving this without having to upgrade from Kore Springs as it breaks when I do and obviously I'd rather not have to update all my code if possible? Link to comment Share on other sites More sharing options...
samme Posted February 26, 2018 Share Posted February 26, 2018 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 More sharing options...
Recommended Posts