【问题标题】:Changing Phaser state from the outside从外部改变 Phaser 状态
【发布时间】:2015-05-07 20:30:30
【问题描述】:

因为我的游戏需要一些用户输入,所以我有一个 html 表单,我覆盖在游戏顶部。单击表单中的取消按钮时,我想更改为不同的状态(并删除表单)。

我不能调用像 this.game.state.start('mainscreen') 这样的东西,因为表单在 Phaser 之外,所以它不知道 this.game 是什么。

我可以通过调用Phaser.GAMES[0].state.start("MainScreen") 来做到这一点,但这感觉不对。这样做的正确方法是什么?

【问题讨论】:

    标签: javascript html dom canvas phaser-framework


    【解决方案1】:

    如果保存游戏的变量名为yourGame 并在window 中声明,则您应该可以从任何地方调用yourGame.state.start("YourState")

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-10
      • 1970-01-01
      • 2021-03-14
      • 1970-01-01
      • 2020-10-28
      • 2014-11-21
      相关资源
      最近更新 更多