CC UITouches 忽略第二次触摸
我正在尝试使用 UITouch 移动精灵,并且我需要处于多点触摸模式,因为我有一个按钮,在移动精灵时我还需要点击。
问题是,当我错过按钮并用另一根手指敲击屏幕时,第二根手指开始触摸,这导致我的精灵跳跃位置。 任何解决办法。我尝试将按钮放在自己的类中,但这没有帮助。 我之所以不只是将所有代码放入触摸移动中,是因为我正在计算从触摸开始的偏移量。
-(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
NSSet *allTouches = [event allTouches];
switch ([allTouches count]) {
case 1:{
NSLog(@"moving touch 1");}break;
所以现在发生的是当我在屏幕上移动手指时 它检测到移动 1 但一旦我放上第二根手指它就停止移动 1 我不想让它停止移动 1
I'm trying to move a sprite around using UITouch and i need to be in multi touch mode because i have a button i also need to hit while i'm moving my sprite around.
The issue is when i miss the button and i hit the screen with my other finger the second finger becomes the touches begins which cause my sprite to jump positions.
Any work around. I tried putting by button in its own class but that didn't help.
The reason why I'm not just putting all the code in touches moved is because I'm calculating the offset from the touches began.
-(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
NSSet *allTouches = [event allTouches];
switch ([allTouches count]) {
case 1:{
NSLog(@"moving touch 1");}break;
So now what is happening is when i move my finger across the screen
it detects moving 1 but once i put on the second finger it stops moving 1
i don't want it to stop moving 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的
-touchesBegan:
方法中,您是否测试触摸点以查看它是否在图像内部?In your
-touchesBegan:
method, are you testing the point of the touch to see if it’s inside the image?在两个按钮触摸上设置一个条件,并且不包含任何其他情况,以避免其他触摸。
喜欢:
希望这会有所帮助。
put a condition on both button touch and don't include any else case there that will be all to avoid other touches.
Like :
Hope this will help.