You may hate gravity, but gravity does not care.
The ability to detect motion opens a world of possibilities for interaction and game design. Motion sensor technology can be used to create an intuitive, life-like user interface, a control mechanism in gaming, or a new kind of brush for animation.
In this chapter we will discuss how to detect motion, and we will go over some examples that make use of this information.
Your Android device contains an onboard sensor that measures acceleration along the perpendicular axes—on the x-axis from left to right, on the y-axis from bottom to top, and on the z-axis from back to front. It calculates the forces affecting the device, both gravity and user movement. Figure 8-1 depicts acceleration measurement along the perpendicular axes on an Android device.
flash.sensors.Accelerometer class is an addition to ActionScript to support
receiving messages from the device’s motion sensor. It is a subclass
EventDispatcher class. The
class is a new
Event class that
returns the sensor’s updated information.
When using these classes, you should first check at runtime that the user’s device has a motion sensor and that it is available for reading. ...