簡體   English   中英

移相器-Game.Physics.Arcade.moveToPointer不起作用?

[英]Phaser - Game.Physics.Arcade.moveToPointer not working?

我試圖使用game.physics.arcade.moveToPointer(sprite,speed,pointer,maxTime)將一個精靈移動到另一個精靈的中心,另一個精靈是Group對象的子代。

這是一個示例:game.physics.arcade.moveToPointer(ball,100,cups.children [0] .body.center,1000);

在創建我的名為ball的精靈,一個名為cups的組以及該組的子級之后,我在create函數中調用了此函數。 我還對所有這些啟用了物理學,以便可以移動它們。

我也嘗試將其移至更新功能,但我的球仍未移向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)驗證了它不為null。

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

會將其標記為對moveToPointer可能存在相同問題的其他任何人的答案

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM