Sprite Touch Move - RPG Tutorial 9
This post will show you have to implement touch events to make our sprite move.
First off let’s add a touch handler function that will serve as our
update() function for mobile touch. Let’s place this function right after our function
Now we need to plug it up with some event listeners. One for touchstart and one for touchmove, see the code block below. Place this right above our
touchHandler(). Along with two global variables: lastY & lastX.
That should do it! Take a look at the demo below or download the source files for this tutorial that includes everything we’ve reviewed so far!
Demo the thing..
Download Source Files
If you would like the source files for this tutorial: Download source files