パノラマのように、X 軸に沿ってデバイスの動きを直線で追跡したい。
加速度計を試してみましたが、これを追跡できません。
デバイスの回転のみを検出すると思います。Grayscope、Magnetometer などのチュートリアルをよく検索します。
コアモーションのサンプルを教えてください。
これを解決するのを手伝ってください。
ありがとうございました。
私のコードは次のとおりです。
- (void)viewDidLoad
{
[super viewDidLoad];
xval=0;
motionManager = [[CMMotionManager alloc] init];
motionManager.deviceMotionUpdateInterval = 1.0/60.0;
NSOperationQueue *aQueue = [NSOperationQueue alloc];
[motionManager startDeviceMotionUpdatesToQueue:aQueue withHandler:^(CMDeviceMotion *motion, NSError *error) {
NSLog(@"X value is: %f", motion.userAcceleration.x);
if (motion.userAcceleration.x > 0.05) {
//a solid move forward starts
//lineLength++; //increment a line length value
xval=xval+10;
ball.frame=CGRectMake(xval, 361, 119, 104);
}
if (motion.userAcceleration.x < -0.02 ) {
[motionManager stopDeviceMotionUpdates];
}
}];
}