有没有人能给我举一个使用Monotouch的陀螺仪的例子?我不知道如何响应陀螺仪更新事件。
谢谢!
发布于 2011-07-20 14:31:44
下面是一个简单的例子:
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属性的三个值中的每个值都是每秒在每个轴上旋转的角度(以弧度为单位)。
https://stackoverflow.com/questions/6756585
复制相似问题