Objective-C 使用加速计 (iPhone)

发布于 2024-08-29 07:04:13 字数 473 浏览 3 评论 0原文

我有一个名为 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”,但我猜这是因为我还没有在实际设备上运行它?

I have a class called MainGame, which is defined like this in my .h:

@interface MainGame : Renderer <UIAccelerometerDelegate>

Then later in my .m I have this:

- (void) accelerometer: (UIAccelerometer *)accelerometer didAccelerate: (UIAcceleration *)acceleration {
    // here I would read values like accelerometer.x
    NSLog(@"accelerated!!1");
}

Am I doing it right?

Currently I'm only testing in iPhone simulator, I'm going to buy the apple $99 developer thing soon. It doesn't log "accelerated!!1", but I'm guessing that's because I'm not running it on an actual device yet?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南冥有猫 2024-09-05 07:04:13

正确的。 iPhone模拟器不提供加速计服务。

您可能会发现这很有用:http://code.google.com/p/ accelerometer-simulator/wiki/Home

还有一个,它允许您在模拟器中使用手机输入(警告,App Store 链接,也有 Lite 版本):http://itunes.com/app/iSimulate

Correct. The iPhone simulator does not provide Accelerometer services.

You may find this useful: http://code.google.com/p/accelerometer-simulator/wiki/Home

There is also this, which allows you to use phone input in the simulator (warning, App Store link, also has a Lite version): http://itunes.com/app/iSimulate

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文