获取ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event的发件人触摸 [英] Get the sender touch for ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

查看:74
本文介绍了获取ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event的发件人触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在多点触摸cocos2d应用中找到名为 ccTouchesMoved:(NSSet *)touchwithEvent:(UIEvent *)event 的触摸是什么?我可以使用 [event allTouches] 获得所有触摸,但是如何找到调用该函数的触摸,例如,当我希望特定触摸显示特定的NSLog时.

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.

推荐答案

touch事件为您的每个手指提供了一个UITouch *对象.从开始到结束/取消,UITouch *在整个触摸过程中都保持不变.您可以将UITouch *保留在begin事件中,并在end和canceled事件中释放它(并将其设置为nil).

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.

顺便说一句,输入类KKInput(类参考)( Kobold2D )(改进的Cocos2D使这变得非常容易.从Preview 5开始,您可以因为KKInput会为您跟踪触摸,所以可以在任何时间,任何类或方法下随时列出当前触摸.

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.

这篇关于获取ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event的发件人触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆