Hi there!
I'm working in a Cocos2D game that uses accelerometer. The game runs well on every iPhone (from 1G to 3GS), however when testing it on an iPod Touch (a couple of them in fact) the accelerometer does not respond, but it doesn't gives any error (but it works well in other games)... Here is the code I'm using:
Code:
// GameScene class, that inherits from Cocos2D's CCLayer...
-(id) init
{
if( (self=[super init])) {
self.isTouchEnabled = YES;
self.isAccelerometerEnabled = YES;
(... more code ...)
}
return self;
}
- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
float accelX = (float) (acceleration.x - calibration.x) * (kGravityConst / 1.5f);
float accelY = (float) (acceleration.y - calibration.y) * (kGravityConst / 1.5f);
space->gravity = ccp(-accelY, accelX);
}
Why can this be happening?
Thanks in advance!