I am making a simple, tilt controlled game using UIKit. So far, when I tilt the device the character moves in the appropriate direction. What I want him to do is to change the direction he is facing when I tilt the device. For example, when I tilt it left, I want the character to face left. Is there a way to detect whether the device was tilted left or right? If so, could you point me in the right direction please. Thanks, Tate
0
votes
2 Answers
0
votes
0
votes
In John Ray's book titled iOS5 Application Development in 24 Hours, chapter 18 illustrates using the CMotionManager to get accelerometer and gyroscope data. Check out the following URL. You can download the source code and load up Chapter 18's ColorTilt application. It contains examples of how to use the gyroscopic information to determine which direction the device was tilted.
http://www.informit.com/store/sams-teach-yourself-ios-5-application-development-in-9780672335761