box2d body / cocos2d精灵的捏手势

时间:2012-04-15 03:46:10

标签: objective-c cocoa-touch cocos2d-iphone box2d uigesturerecognizer

我想在cocos2d iPhone中检测box2d机身上的捏,但我不知道从哪里开始。对象很简单b2cirleshapes。我知道ios有uipinchgeasture识别器,但我不知道这是不是这样或如何在box2d对象上实现它。 谢谢你!

1 个答案:

答案 0 :(得分: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
}

}