Created
July 13, 2017 23:10
-
-
Save kdelwat/4651f9af2e0f050cfd4edc601eea6334 to your computer and use it in GitHub Desktop.
Touch controls for Code Camp World
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mouseDeadZone = 50; | |
if (this.game.getMouseX() > this.getXPosition() + mouseDeadZone) | |
{ | |
this.setXSpeed(100); | |
this.setYSpeed(0); | |
this.playAnimation('Right'); | |
} | |
else if (this.game.getMouseX() < this.getXPosition() - mouseDeadZone) | |
{ | |
this.setXSpeed(-100); | |
this.setYSpeed(0); | |
this.playAnimation('Left'); | |
} | |
else if (this.game.getMouseY() < this.getYPosition() - mouseDeadZone) | |
{ | |
this.setXSpeed(0); | |
this.setYSpeed(-100); | |
} | |
else if (this.game.getMouseY() > this.getYPosition() + mouseDeadZone) | |
{ | |
this.setXSpeed(0); | |
this.setYSpeed(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment