Is there any method to pause a running game and resume back (using a button) in Phaser-3 framework? The one given for Phaser-2 is not working.
Call game. scene. pause("default") if you have only the default scene. If you have more call it like this game.
Then you check if the button p is pressed. If yes, then you toggle the pause value (pause = ! pause). As for the text, you can either use the text method or use an image.
In phaser3 you can have several scenes running in parallel. So you can create a new scene with the resume button and pause the current scene. If you have 2 scenes A e B you can do:
# In scene A
this.scene.launch('sceneB')
this.scene.pause();
# Then in sceneB, you can return to sceneA:
button.on('pointerdown', function() {
this.scene.resume('sceneA');
this.scene.stop();
})
Call game.scene.pause("default")
if you have only the default scene. If you have more call it like this game.scene.pause(sceneKey)
.
Docs at: https://photonstorm.github.io/phaser3-docs/Phaser.Scenes.SceneManager.html
If you just want to freeze a character, you can use this.sprite.body.moves = false;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With