내 게임의 한 지점에는 번 가속도계 사용이 있습니다.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];
를 사용해야하지만 분명히 당신을 위해 그 방법을 설정해야 그렇게 멈춰. 나는 그것을 끝내기 위해 내가 어떻게 그것을 바꿔야 만합니까 ?? 또는 내가 가진 것을 사용하여 끝낼 수 있습니까? nil
에 가속도계의 대리자를 설정
미리 감사드립니다,
중동