+ 1

How can I detect if the touch that was released was the same touch that had started?

I have made a joystick, and when the touch is released I make it return back to center, the problem is that if I touch the screen with another finger and release it then it will still return the joystick to the center, how can I make sure this only happens once the touch that is moving the joystick is released? Here is the code: https://code.sololearn.com/WttB7NsJJq1k/?ref=app

6th Apr 2021, 4:40 PM
Karak10
Karak10 - avatar
1 ответ
+ 1
I'm getting no replies, but it's okay because I figured out a way to do this on my own, I created a variable that is updated to clientX property of the touch which is moving the joystick every time touchmove event is triggered, then after a touch is released I check wether changedTouches[0].clientX matches that variable's value. I don't know if that's the best way to do this but it seems to work.
6th Apr 2021, 6:43 PM
Karak10
Karak10 - avatar