Game Development Reference
In-Depth Information
then check the state and properties of the gesture at any time. For cocos2d, this
forum thread is a good starting point for a gesture recognizer implementation:
www.cocos2d-iphone.org/forum/topic/8929 .
Receiving Accelerometer Events
Like touch input, the accelerometer must be specifically enabled to receive accelero-
meter events:
self.isAccelerometerEnabled = YES;
Once more, you add a specific method to the layer that receives the accelerometer
events:
-(void) accelerometer:(UIAccelerometer *)accelerometer
didAccelerate:(UIAcceleration *)acceleration
{
CCLOG(@"acceleration:x:%f/y:%f/z:%f", ←
acceleration.x, acceleration.y, acceleration.z);
}
You can use the acceleration parameter to determine the acceleration in any of
the three directions.
Tip The KKInput class in Kobold2D not only does accelerometer input, it
also provides a simple interface to the gyroscope. For both accelerometer and
gyroscope, you can access the high-pass and low-pass filtered values via prop-
erties.
Receiving Keyboard Events
If you're creating a Mac OS X app, you want to be able to process keyboard presses.
You first have to enable keyboard events:
Search Nedrilad ::




Custom Search