0

我想检测在cocos2d iPhone box2d身体捏,但我不知道从哪里开始。对象是简单的b2cirleshapes。我知道ios有uipinchgeasture识别器,但我不知道这是否是要走的路或如何在box2d对象上实现它。 感谢堆!捏手势box2d身体/ cocos2d精灵

回答

1

试试这个 -

UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGesture:)]; 
[self.box2d addGestureRecognizer:pinchGesture]; 

与本 -

- (void)pinchGesture:(UIPinchGestureRecognizer *)pinch { 
if (pinch.velocity < 0) { 
    //close pinch 
} 
else { 
    //open pinch 
} 

}

+0

我觉得我失去了一些东西,因为它说 '实例方法-addGestureRecognizer没有找到' 当我尝试将其添加到box2D主体或精灵。 – glenstorey 2012-04-16 00:57:46

+0

修复它 - 编辑你的答案,手势识别器需要在openGLView(http://stackoverflow.com/a/5019536/459116)上。感谢您的帮助,一旦编辑完成,我会接受您的答案。 – glenstorey 2012-04-16 01:54:02

+0

是的,这将起作用。我不确定您查看的对象是否被命名。 – Dmorneault 2012-04-17 01:37:13