I’ve read pretty much every tutorial and Stack Overflow question involving accelerometer-controlled SpriteKit games and I’ve noticed that people often use the
startAccelerometerUpdatesToQueue:withHandler: method to collect accelerometer data. However, there is another approach (which I use), which is to simply call
startAccelerometerUpdates. Confused about the difference, I decided to hit the CMMotionManager class reference and found the following:
An app can take one of two approaches when receiving motion data, by handling it at specified update intervals or periodically sampling the motion data.
Is it just me or do those two things sound kinda the same? Anyway, moving on…under the second approach, “Periodic Sampling of Motion Data,” it says:
To handle motion data by periodic sampling, the app calls a “start” method taking no arguments and periodically accesses the motion data held by a property for a given type of motion data. This approach is the recommended approach for apps such as games. Handling accelerometer data in a block introduces additional overhead, and most game apps are interested only the latest sample of motion data when they render a frame.
I just wanted to point this out in case someone is thinking of making an accelerometer game and isn’t sure which method to use.