I tried using a shaking gesture recognition system to detect a shaking gesture. I also tried to implement the code suggested by Geeky Lemon . But I can't handle the shake gesture. Is there a way to recognize a shake gesture?
Thank!
EDIT 1:
The code is executed using a demo program to demonstrate hard gesture recognition.
in init method
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"); } }
Create your gesture recognizer in the usual way, and then add it like this:
[[[CCDirector sharedDirector] view] addGestureRecognizer:shakeGesture];
ShakeEnabledUIWindow UIWindow. AppDelegate , ,
ShakeEnabledUIWindow
UIWindow
AppDelegate
#import "ShakeEnabledUIWindow.h"
@property (strong, nonatomic) ShakeEnabledUIWindow *window;
. Shake Gesture.
Shake Gesture