How does one manage multiple touchStarted events?

I'm trying to work out how the touchStarted and touchEnded functions fit into the whole 'Multi-Touch' image.

But so far what happens is that when the touchStarted event is fired, and the touch is still ongoing, the next touch that you're trying to do while the first one is still touching doesn't fire the touchStarted event.

Maybe i'm overlooking something bigger?

Tagged:

Answers

  • I haven't checked, but I don't think that is how you detect additional fingers being added during a touch event. Instead you check the length of touches[].

  • @jeremydouglass hmm, I'll have to try this out. Thanks!

  • edited May 2017

    Hi, Thanks! this was the solution: I loop through the touches array and compare the touches x,y to the button's x,y. works like a charm!

    for (var i = 0; i < touches.length; i ++) {
      var d = dist(touches[i].x, touches[i].y, foo.x, foo.y);
      if (d < foo.r) {
        //do something
      }
    }
    
  • @SaintPepsi -- congratulations. Glad it worked, and thanks for sharing your solution.

  • I've added a little snippet of code in case someone is wondering what it looks like.

    Thanks again for the tip.

Sign In or Register to comment.