0
votes

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....

1
P.S. No errors are being thrown in the JS console. - JohnWick
The correct tag is phaser-framework, please use that from now on. - Daedalus

1 Answers

0
votes

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