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

醉酒当歌 提交于 2019-12-12 03:21:38

问题


How can i find in a multi touch cocos2d app what 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.


回答1:


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.



来源:https://stackoverflow.com/questions/7595298/get-the-sender-touch-for-cctouchesmovednsset-touches-witheventuievent-ev

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!