O'Reilly logo

Marmalade SDK Mobile Game Development Essentials by Sean Scaplehorn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting accelerometer input

The final input method we will be considering in this chapter is the accelerometer, which allows us to detect the orientation that the user is currently holding the device at. An accelerometer is a sensor that can measure the forces applied to a device, be they static forces such as gravity, or dynamic forces generated by waving the device around.

Most devices will have three accelerometers aligned perpendicularly to each other, as shown in the following diagram. This configuration allows us to discover exactly how the user is holding the device at any time and so provides a method of controlling our game.

Detecting accelerometer input

The directions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required