本文介绍了UIPinchGestureRecognizer - 禁止“关闭夹点”检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UIPinchRecognizer和一个打开的夹子来检测当有人在Box2D世界中分割sprite时。



问题是,当你拖动两个项目朝向彼此,它检测这是一个关闭捏和打破所有我的touchjoints和box2d对象的运动。



我试图把我的问题分成两个问题 - 您现在正在阅读的问题:是否可以抑制关闭捏,如果这是不可能的:如何检测



我需要抑制关闭夹点的检测,或者编写自己的打开夹点检测。



我试着从pinch手势方法返回一个打开的pinch像这样:

  if(pinch.velocity < 0){
// close pinch
return;
}

但它不工作,因为它仍然断开touch关节/ box2d对象。



您能帮我解决这个问题吗?

解决方案

我需要在设备上检查这个,但我认为这已经修复了:

  // Multitouch / pinch? 
UIPinchGestureRecognizer * pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGesture :)];
pinchRecognizer.cancelsTouchesInView = NO; //这解决了它,因为它阻止鼠标关节坏了。

[[[CCDirector sharedDirector] openGLView] addGestureRecognizer:pinchRecognizer];
[UIPinchGestureRecognizer release];



<$>

p $ p> if(pinch.velocity< 0){
return;
}


I'm using the UIPinchRecognizer and an open pinch to detect when someone 'pulls apart' a sprite in a Box2D world.

The problem is that when you drag two items toward each other it detects this as a close pinch and breaks all my touchjoints and the movement of the box2d objects.

I've tried to split my problem into two questions - the question you're reading now: is it is possible to suppress the close pinch, and if that's not possible: how to detect an open pinch myself.

I need to either suppress the detection of close pinches or write my own open pinch detection.

I tried returning from the pinch gesture method on an open pinch like this:

if (pinch.velocity < 0) {
    //close pinch
    return;
}

but it doesn't work because it still breaks the touch joints / box2d objects.

Could you help me solve this problem by suppressing the detection of close pinches?

解决方案

I need to check this on a device, but I think that this has fixed it:

//Multitouch / pinch?
UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGesture:)];
pinchRecognizer.cancelsTouchesInView = NO; //This fixes it because it stops the mouse joints getting broken. 

[[[CCDirector sharedDirector] openGLView] addGestureRecognizer:pinchRecognizer];
[UIPinchGestureRecognizer release];

with this in the pinchGesture method:

if(pinch.velocity <0 ){
    return;
}

这篇关于UIPinchGestureRecognizer - 禁止“关闭夹点”检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 00:07