Move Sprite to the mouse position with Phaser

Asked

Viewed 146 times

1

I need to move a Sprite to the mouse position, I used the function game.physics.arcade.moveToPointer(), but only works with sprites who have the body of the type Phaser.Physics.Arcade.

How do I use this function using a type body Phaser.Physics.P2JS? https://codepen.io/salomaosnff/pen/LQXWPv

1 answer

0

there is this method:

update() {
    this.player.x = game.input.x;
    this.player.y = game.input.y;
}
  • I even tried it this way, but then I can’t adjust some parameters like speed. The best solution I found was rewriting the functions moveToPointer, distanceToPointer and angleToPointer in a separate file.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.