我有一个名为MainGame的类,它在我的.h中定义如下:
@interface MainGame : Renderer <UIAccelerometerDelegate>然后,在稍后的.m中,我有以下内容:
- (void) accelerometer: (UIAccelerometer *)accelerometer didAccelerate: (UIAcceleration *)acceleration {
// here I would read values like accelerometer.x
NSLog(@"accelerated!!1");
}我做得对吗?
目前我只在iPhone模拟器中测试,我很快就会购买苹果的99美元开发者的东西。它没有记录“加速!!1”,但我猜这是因为我还没有在实际的设备上运行它?
发布于 2010-04-16 18:08:48
对,是这样。iPhone模拟器不提供加速度计服务。
你可能会发现这很有用:http://code.google.com/p/accelerometer-simulator/wiki/Home
还有一个,它允许你在模拟器中使用手机输入(警告,App Store链接,也有一个精简版本):http://itunes.com/app/iSimulate
https://stackoverflow.com/questions/2652005
复制相似问题