Tag Archives: THRESHOLD

How to detect shake Gesture in your iPhone Cocos2D?

By | February 26, 2011

For detecting shake in a cocos2D program copy these lines to your layer class bool shaked_once; //default false self.isAccelerometerEnabled = YES; [[UIAccelerometer sharedAccelerometer] setUpdateInterval:1/60]; shaked_once = false; Then copy this function to the same file…. and you are done…….. -(void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { float THRESHOLD = 2; if (acceleration.x > THRESHOLD || acceleration.x… Read More »