O'Reilly logo

Mastering Cocos2d Game Development by Alex Ogorek

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

Setting gravity by tilting the device

When your user tilts the device, the device's accelerometer will pick up that information at even the slightest, most minute values. This is beneficial to those who wish to use the accelerometer (or tilting) within their game, especially with regards to moving the character or manipulating gravity, which is what we'll cover in this section.

Ever since iOS 5.0, UIAccelerometer has been replaced by the Core Motion framework data. Thankfully, it's no more complicated, so let's get started.

Tip

If you aren't a registered developer and can't use your actual device to test (and have been doing so on the simulator), note that it's not possible to test the accelerometer with the simulator unless the data can be sent ...

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