Get the sender touch for ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
How can i find in a multi touch cocos2d app w开发者_StackOverflow中文版hat was the touch that called ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
? I can get all the touches using [event allTouches]
but how can i find which touch called the function, for example when i would like for that specific touch to display a specific NSLog.
The touch events provide you with a UITouch* object for each finger. The UITouch* remains the same throughout the whole touch, from began to ended/cancelled. You can retain the UITouch* in the began event and release it (and set it to nil) in the ended and cancelled events.
Btw, the input class KKInput (class reference) of Kobold2D (improved Cocos2D makes that a whole lot easier. Starting with Preview 5 you can just get the list of current touches at any time, in any class or method because KKInput keeps track of the touches for you.
精彩评论