Guest User

Untitled

a guest
Jul 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. function update() {
  2. // This depends upon pointerOrigin (Phaser.Point) being defined. You'll also need to update 'player' to match your specific needs.
  3. if (this.game.input.activePointer.isDown) {
  4. if (this.pointerOrigin) {
  5. this.player.position.x += this.game.input.activePointer.position.x - this.pointerOrigin.x;
  6. this.player.position.y += this.game.input.activePointer.position.y - this.pointerOrigin.y;
  7. }
  8. // Keep track of where the pointer has been so we can use it for the next update cycle.
  9. this.pointerOrigin = this.game.input.activePointer.position.clone();
  10. }
  11. else {
  12. this.pointerOrigin = null;
  13. }
  14. }
Add Comment
Please, Sign In to add comment