在 Phaser 3 中暂停和恢复游戏
Pause and Resume Game in Phaser 3
在 Phaser-3 框架中是否有任何方法可以暂停 运行 游戏并恢复(使用按钮)?为 Phaser-2 提供的那个不起作用。
在 phaser3 中,您可以并行处理多个场景 运行。因此,您可以使用恢复按钮创建新场景并暂停当前场景。如果你有 2 个场景 A e B 你可以这样做:
# 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();
})
如果只有默认场景,请调用game.scene.pause("default")
。如果你有更多这样的称呼 game.scene.pause(sceneKey)
.
文档位于:https://photonstorm.github.io/phaser3-docs/Phaser.Scenes.SceneManager.html
如果你只是想冻结一个角色,你可以使用this.sprite.body.moves = false;
在 Phaser-3 框架中是否有任何方法可以暂停 运行 游戏并恢复(使用按钮)?为 Phaser-2 提供的那个不起作用。
在 phaser3 中,您可以并行处理多个场景 运行。因此,您可以使用恢复按钮创建新场景并暂停当前场景。如果你有 2 个场景 A e B 你可以这样做:
# 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();
})
如果只有默认场景,请调用game.scene.pause("default")
。如果你有更多这样的称呼 game.scene.pause(sceneKey)
.
文档位于:https://photonstorm.github.io/phaser3-docs/Phaser.Scenes.SceneManager.html
如果你只是想冻结一个角色,你可以使用this.sprite.body.moves = false;