【问题标题】:How to make player restrict of boundries only left right not up and down in phaser js game?在phaser js游戏中,如何使玩家的边界限制只在左右而不是上下?
【发布时间】:2022-06-11 00:40:54
【问题描述】:

在phaser js游戏中,如何让玩家只限制左右边界而不是上下边界?

【问题讨论】:

    标签: phaser-framework


    【解决方案1】:

    您可以使用函数this.physics.world.setBounds(...) 设置自定义世界边界。 Here a link to the documentation.

    因此,您只需将这一行放入您的代码中:

    `this.physics.world.setBounds(0, 0, widthOfTheGame, heightOfTheGame, true, true, false, true);`.
    

    create 函数中。

    按照文档setBounds(x, y, width, height [, checkLeft] [, checkRight] [, checkUp] [, checkDown])

    第三个false 用于world-bounds-top,因此不会发生碰撞。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多