我尝试使用摇动手势识别包装器来检测摇动手势。我还尝试实现Geeky Lemon中建议的代码。但我无法处理摇晃手势。有什么方法可以识别摇晃手势吗?
谢谢!
编辑1:
代码是在摇动手势识别包装演示的帮助下完成的。
在初始化方法中
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");
}
}