iPhone Accelerometer still not registering!

I have a game where you control the character with the accelerometer. The problem is the accelerometer works about 90% of the time, the other 10% it doesn't seem to be sending any data.(So the player is unable to move)

I've heard changing the color-format to kEAGLColorFormatRGBA8 often solves this problem but it didn't for my app. Here is the code
// Get the layer
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;

eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];


I've also heard you need to specific the delegate first when you start the accelerometer.
//Configure and start accelerometer
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)];


Finally, here is where I do my accelerometer calculations:
// Implement this method to get the lastest data from the accelerometer 
- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
//Use a basic low-pass filter to only keep the gravity in the accelerometer values
_accelerometerX = acceleration.x * kFilteringFactor + _accelerometerX * (1.0 - kFilteringFactor);
}


Does anyone see where I'm making my mistake?

Mac Pro, Two 3GHz Dual-Core Intel Xeon, 410 GB HD, NVIDIA 7300 GT, Mac OS X (10.5.2), Macbook Air, 1.6GHz Core 2 Duo, 80GB HD, 2GB RAM

Posted on Sep 9, 2008 10:16 AM

Reply
23 replies

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

iPhone Accelerometer still not registering!

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.