【发布时间】:2011-07-20 03:09:55
【问题描述】:
谁能给我提供一个关于如何将陀螺仪与 Monotouch 一起使用的示例?我不知道如何响应陀螺仪更新事件。
谢谢!
【问题讨论】:
标签: iphone xamarin.ios gyroscope
谁能给我提供一个关于如何将陀螺仪与 Monotouch 一起使用的示例?我不知道如何响应陀螺仪更新事件。
谢谢!
【问题讨论】:
标签: iphone xamarin.ios gyroscope
这是一个简单的例子:
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 属性的三个值中的每一个都是每个轴上每秒的旋转角度量,以弧度为单位。
【讨论】: