I want to have my game so that you can control movement of the player by tilting the device, however when I used your accelerometer code nothing happens. Is there something I am missing? At the top of AppDelegate.m I have
#define kAccelerometerFrequency     10 //Hz
In the middle of the file, right before gameLogic, I have
- (void) configureAccelerometer {
UIAccelerometer* theAccelerometer = [UIAccelerometer sharedAccelerometer];
if (theAccelerometer) {
theAccelerometer.updateInterval = 1 / kAccelerometerFrequency;
theAccelerometer.delegate = self;
}
else {
NSLog(@"Oops we're not running on the device!");
}
}
- (void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
UIAccelerationValue x, y, z;
x = acceleration.x;
y = acceleration.y;
z = acceleration.z;
NSLog(@"X:%f Y:%f Z:%f", x, y, z);
// Do something with the values.
//xField.text = [NSString stringWithFormat:@"%.5f", x];
//yField.text = [NSString stringWithFormat:@"%.5f", y];
//zField.text = [NSString stringWithFormat:@"%.5f", z];
}
I tried my code on a device with the console window open, and it didn't do anything. My device is a second gen iPod Touch. Any help is much appreciated!