我試過使用shake Gesture Recognition wrapper來檢測搖動手勢。 我也試着實現Geeky Lemon中建議的代碼。 但我無法處理握手。有什麼方法可以識別搖動手勢嗎?如何在Cocos2d CCLayer中添加Shake Gesture?
謝謝!
編輯1:
代碼由搖晃手勢識別包裝演示的幫助下完成。
在init方法ShakeDispatcher * dispatcher = [ShakeDispatcher sharedInstance];
[dispatcher addShakeListener:self];
[[[CCDirector sharedDirector]view] addGestureRecognizer:dispatcher];
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.subtype == UIEventSubtypeMotionShake){
NSLog(@"Shake detected");
}
}
我試過了,但沒有奏效。 – Marine
爲你嘗試的 –
添加一些代碼請檢查編輯1中的代碼 – Marine