0
在我的遊戲中有一個簡短使用加速度計。我用這個代碼:關閉iPhone加速度計,但不使用它
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
accel.updateInterval = 1.0f/60.0f;
開始加速,然後使用更新:
- (void)accelerometer:(UIAccelerometer *)accellerometer didAccelerate:(UIAcceleration *)acceleration {
if (whichLevel == 24) {
//Blah blah blah, using accelerometer
} else {
//Turn accelerometer off somehow?
}
//I have found out using this:
NSLog(@"Accelerometer being used");
//That the accelerometer is being used after I start it in the game.
}
,當然還有,在我把 這種代碼在多個使用比.H一些教程 - 但我的觀點是,這隻用了一小段時間,我想在不使用它的時候關掉它。 (其中沒有教程教你如何做)
蘋果似乎在這裏說:http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MotionEvents/MotionEvents.html - 你應該使用
[motionManager stopAccelerometerUpdates];
但顯然你必須爲它設置了這種方式來這樣停下來。我是否必須改變設置方式才能結束?或者我可以用我擁有的東西來結束它?
由於提前,
的我