【发布时间】:2014-01-31 14:40:51
【问题描述】:
我正在尝试让我的游戏在 Android 上运行。我已经将它移植到 Apportable 的免费版本中,效果很好,但我无法实现陀螺仪功能。
CMMotionManager 被初始化,但运动更新永远不会开始(或者至少handleDeviceMotion: 永远不会被调用)。运动管理器的isAccelerometerActive 属性始终为NO,但isAccelerometerAvailable 为YES。
使用[NSOperationQueue mainQueue] 也无济于事。
这就是我初始化运动管理器的方式:
self.motionManager = [[CMMotionManager alloc] init];
self.motionManager.gyroUpdateInterval = .2;
[self.motionManager startDeviceMotionUpdatesToQueue:[[NSOperationQueue alloc] init]
withHandler:^(CMDeviceMotion *motion, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[self handleDeviceMotion:motion];
});
}];
它会向 logcat 生成以下消息:
E/Sensors ( 507): HAL:ERR open file /sys/bus/iio/devices/iio:device0/dmp_event_int_on to write with error 2
E/Sensors ( 507): HAL:ERR can't disable DMP event interrupt
我不知道这是什么意思... 我正在 Asus Nexus 7 上测试该应用。
要使用 CoreMotion 和 Apportable,我需要做些什么特别的事情吗?
编辑: Here's 我创建的一个简单的测试项目来演示这个问题。
【问题讨论】:
-
logcat 可能与 CoreMotion 问题无关。你能简化 CoreMotion 初始化吗?
-
@PaulBeusterien 我不确定您所说的简化是什么意思,但我添加了一些有关该问题的信息。
标签: android gyroscope core-motion apportable iio