在Phaser-3框架中,有没有一种方法可以暂停正在运行的游戏并恢复(使用按钮)? 给出的Phaser-2方法不起作用。
在Phaser-3框架中,有没有一种方法可以暂停正在运行的游戏并恢复(使用按钮)? 给出的Phaser-2方法不起作用。
在Phaser3中,您可以同时运行多个场景。因此,您可以使用“恢复”按钮创建一个新场景并暂停当前场景。如果您有2个场景A和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;
。
game.loop.sleep()
和game.loop.wake()
是唯一对我有效的解决方案。 - chylinski