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