在 Phaser 3 中暂停和恢复游戏

新手上路,请多包涵

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

原文由 Akash Abi 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.3k
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();
})

原文由 Ventoh 发布,翻译遵循 CC BY-SA 4.0 许可协议

如果只有默认场景,请调用 game.scene.pause("default") 。如果你有更多这样的称呼 game.scene.pause(sceneKey)

文档位于: https ://photonstorm.github.io/phaser3-docs/Phaser.Scenes.SceneManager.html

原文由 Totty.js 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏