Game Development Reference
In-Depth Information
What just happened?
Yep. With a couple of lines, you added accelerometer controls to your game.
It is common practice to add extra filters to these accelerometer values, as results may vary
between devices. These filters are ratios you apply to acceleration to keep values within a
certain range. You can also find a variety of formulas for these ratios online. But these will
depend on how sensitive you need the controls to be or how responsive.
And, in the game, we only update the Eskimo with the accelerometer data if the sprite is
touching a platform. We can quickly ascertain that by checking whether or not the _play-
er body has a contact list, as follows:
if (_player->getBody()->GetContactList())
Search WWH ::




Custom Search