So I have been trying to wrap my mind around touch controls.
For example, let’s say I place my finger on the screen and then move it to the right, it should know I’m moving to the right, and then from there if I move my finger to the left it should know that too, but the part I’m not sure how to determine is when my finger just stops and doesn’t move. Not sure how to get a function in that situation.
I got it to know when I’m moving right to left, but perhaps my way of doing it isn’t smart. And not sure how to fire off something to know when it’s stopped.
Here’s the code.
PlayerControls.prototype.onTouchMove = function(event){
var touch0 = event.touches[0].x;
if(this.touchX != touch0){
if(this.touchX > touch0){
this.moveLeft();
this.touchX = touch0;
} else if(this.touchX < touch0){
this.moveRight();
this.touchX = touch0;
}
}
};