Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  Ali.S May 27 '11 at 20:51
    
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. –  user586006 May 27 '11 at 21:20
    
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 –  Ali.S May 27 '11 at 21:21
    
Interesting, let me work with this some more and I'll get back to you. Thanks! –  user586006 May 27 '11 at 21:24
    
So in the end, how can you prove what is the latest touch? –  user586006 May 31 '11 at 15:14
show 1 more comment

1 Answer

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).
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.