开发者

Get the sender touch for ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

开发者 https://www.devze.com 2023-04-09 11:40 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号