[SOLVED] Explanation for touch events

TouchInput.prototype.onTouchStart = function(event) { var touches = event.touches; };
How does the event.touches work? If I keep touching at one point it gets stored in touches [0]. If I keep one more finger in the screen, it gets stored in touches [1]. What happens if I lift my first finger? Will the second touch remain in touches[1] or will it move to touches[0]?

For example if touches.length is 1, is it possible that the touch may be touches[1] instead of touches[0]?
How do I know which touch is on the screen?

It will move to touches [0] but will have the same touch I’d as before.

https://developer.playcanvas.com/en/api/pc.Touch.html#id

Every time a touch is registered, it will have an id that doesn’t change until the finger is lifted.

1 Like

Also

this.app.touch.on(pc.EVENT_TOUCHEND, this.onTouchEndCancel, this);

returns an event containing the touches that are still on the screen but not the touch that ended. Is there any way to get the ID and position of the touch that was ended?

It should be in changed touches https://developer.playcanvas.com/en/api/pc.TouchEvent.html#changedTouches

1 Like