有人可以给我提供一个如何在 Monotouch 中使用陀螺仪的示例吗?我不知道如何响应陀螺仪更新事件。
谢谢!
最佳答案
这是一个简单的例子:
using MonoTouch.CoreMotion;
//..
CMMotionManager motionManager;
private void StartGyro()
{
motionManager = new CMMotionManager();
motionManager.GyroUpdateInterval = 1/10;
if (motionManager.GyroAvailable)
{
motionManager.StartGyroUpdates(NSOperationQueue.MainQueue, GyroData_Received);
}
}
private void GyroData_Received(CMGyroData gyroData, NSError error)
{
Console.WriteLine("rotation rate x: {0}, y: {1}, z: {2}",
gyroData.RotationRate.x, gyroData.RotationRate.y, gyroData.RotationRate.z);
}
CMGyroData 实例的 RotationRate 属性的三个值中的每一个都是每个轴上每秒的旋转角度量(以弧度为单位)。
关于iphone - 在 Monotouch 中使用陀螺仪?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6756585/