Handling multi touch in p5.js

I have a sketch where a ball drops from the top and can be controls by touching right side of the screen or left side of the screen.

There is a small bug which is when you keep holding left side of the screen and then press right side of the screen the movement of the ball stops.

Sketch line here

The issue can be replicated only in the touch screen devices.

Is this the correct way of handling this?


  • Yes, but it still the issue lives.

  • ...ok. Without knowing how you attempted to implement multitouch, it is hard to give you further advice.

    What do you want to happen when touching both the left and right side?

  • The last touch should react meaning if the use has touched the right then the ball moves to the right and when the user touches left without releasing the right then the left should react.

  • edited February 2018

    To specify which was the "last touch," then, it sounds like you need to use the touches array, check how many are in there, and then act based on the most recently pressed touch.

    While designing that, you may want to check whether the most recently pressed touch is the first or the last touch in the list -- or if there is no pattern, and you need to keep track of it yourself.

Sign In or Register to comment.