Phaser 3 中的暂停和恢复游戏

Aka*_*Abi 8 javascript phaser-framework

是否有任何方法可以在Phaser-3框架中暂停正在运行的游戏并恢复(使用按钮)?为Phaser-2提供的那个不起作用。

Ven*_*toh 12

在 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();
})
Run Code Online (Sandbox Code Playgroud)