【问题标题】:Phaser - Game.Physics.Arcade.moveToPointer not working?Phaser - Game.Physics.Arcade.moveToPointer 不工作?
【发布时间】:2015-02-04 21:32:26
【问题描述】:

我正在尝试使用 game.physics.arcade.moveToPointer(sprite,speed,pointer,maxTime) 将一个精灵移动到另一个精灵的中心,该精灵是 Group 对象的子对象。

这是一个例子: game.physics.arcade.moveToPointer(ball,100,cups.children[0].body.center, 1000);

我在创建函数中调用它,在创建了我的名为 ball 的精灵、一个名为 cups 的组以及该组的孩子之后。我还启用了所有它们的物理功能,以便它们可以移动。

我也尝试将它移到更新功能,但我的球仍然没有移向cups.children[0]的中心

我做错了什么?

更新:使用

ball.rotation = game.physics.arcade.moveToPointer(ball,100,game.input.activePointer,1000; 

在我的 update() 函数中,会将球移动到鼠标上,但 cups.children[index].body.center 不起作用,即使它也是一个 Pointer 对象,例如 game.input.activePointer。我已经用 console.log(cups.children[0].body.center) 验证它不为空......

【问题讨论】:

  • P.S. JS 控制台中没有抛出任何错误。
  • 正确的标签是phaser-framework,从现在开始请使用它。

标签: javascript html phaser-framework


【解决方案1】:

好吧,我通过使用 game.physics.arcade.moveToObject(sprite,targetSprite,speed); 找到了解决方法

将此标记为其他任何可能对 moveToPointer 有相同问题的人的答案

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-14
    • 2016-04-11
    • 2015-07-21
    • 2015-07-05
    • 2015-04-17
    • 2022-12-08
    • 2022-06-14
    • 1970-01-01
    相关资源
    最近更新 更多