I am trying to move one sprite to the center of another sprite, which is a child of a Group object, using game.physics.arcade.moveToPointer(sprite,speed,pointer,maxTime).
Here is an example: game.physics.arcade.moveToPointer(ball,100,cups.children[0].body.center, 1000);
I am calling this in the create function, after creating my sprite called ball, a group called cups, and the children of that group. I am also enabling physics on all of them, so that they can be moved.
I also tried moving it to the update function, but my ball still does not move towards the center of cups.children[0]
What am I doing wrong?
UPDATE: Using
ball.rotation = game.physics.arcade.moveToPointer(ball,100,game.input.activePointer,1000;
In my update() function will move the ball to the mouse, yet cups.children[index].body.center does not work, even though it is also a Pointer object, like game.input.activePointer. I have verified with console.log(cups.children[0].body.center) that it is not null....
Well, I found a work around by using game.physics.arcade.moveToObject(sprite,targetSprite,speed);
Will mark this as the answer for anyone else that might have the same problem with moveToPointer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.