In Cocos2D for iPhone, I want the latest touch event to interrupt another and ignore the last touch. Let me know if I need to elaborate more, but basically my game consists of a lot of finger dragging, and if the player ever switched fingers, there may be some overlap, and for the way things are setup, it may detect it as a new touch.

I think I have things almost on the right track, but my third touch does not work correctly. For instance:

  • Touch A begins and held
  • Touch B begins and held
  • Touch A let go
  • Touch A begins and held <-This should interrupt Touch B

In my delegate I put [glView setMultipleTouchEnabled:YES]; because I believe I need multiple touches enabled.

In my CCLayer class with my added map and sprite I am using targeted touch delegate (i.e. ccTouchBegan NOT ccTouchesBegan, etc)

I am accessing a touch object with touch = [[[event allTouches] allObjects] objectAtIndex:0];, however I don't have much understanding what index is considered the latest touch or even a process to always get the latest touch.

  • \$\begingroup\$ as much as I know all touches keep their numbers until they end. consider the below senario: *touchA begin -> index 0 *touchB begin -> A = 0 , B = 1 *touchA end -> B = 1 *touchC begin -> C = 0 , B = 1 *touchB end -> C = 0 and their index is always the same for each of touchbegin ,touchmoved, and touch end. \$\endgroup\$
    – Ali1S232
    Commented May 27, 2011 at 20:51
  • \$\begingroup\$ Okay, maybe what I didn't understand was that when you do something like touch = [[[event allTouches] allObjects] objectAtIndex:0];, you're actually SETTING that touch to index 0? I thought that meant the touch equaled the touch event at index 0. \$\endgroup\$
    – exactspace
    Commented May 27, 2011 at 21:20
  • \$\begingroup\$ that means touch at index 0, but when the second touch starts and the first touch not ended yet cocos2d will store it in index 1 \$\endgroup\$
    – Ali1S232
    Commented May 27, 2011 at 21:21
  • \$\begingroup\$ Interesting, let me work with this some more and I'll get back to you. Thanks! \$\endgroup\$
    – exactspace
    Commented May 27, 2011 at 21:24
  • \$\begingroup\$ So in the end, how can you prove what is the latest touch? \$\endgroup\$
    – exactspace
    Commented May 31, 2011 at 15:14

1 Answer 1


Look at these links, they might help:

I would try to do it this way:

  1. store the events in a list
  2. examine this list in a function which is called after all input has been processed (there might be an event handler for it).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .