Mar*_*ine 5 iphone gesture cocos2d-iphone shake
我已经尝试使用摇动手势识别包装来检测摇动手势.我也试图实现Geeky Lemon中建议的代码.但我无法处理摇晃手势.有没有办法让震动手势得到认可?
谢谢!
编辑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");
}
}
Run Code Online (Sandbox Code Playgroud)
以正常方式创建手势识别器,然后像这样添加它
[[[CCDirector sharedDirector] view] addGestureRecognizer:shakeGesture];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
807 次 |
| 最近记录: |