我试过使用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