Game Development Reference
In-Depth Information
Figure 4-8. Pressing the Shift and A keys simultaneously
There are a couple of things to note here:
ï?®
When you look at the LogCat output, notice that we can easily process
simultaneous key events. Holding down multiple keys is not a problem.
ï?®
Pressing the D-pad and rolling the trackball are both reported as key events.
ï?®
As with touch events, key events can eat up considerable CPU resources
on old Android versions and first-generation devices. However, they will not
produce a flood of events.
That was pretty relaxing compared to the previous section, wasn't it?
Note The key-processing API is a bit more complex than what we have shown here. However, for
our game programming projects, the information contained here is more than sufficient. If you need
something a bit more complex, refer to the official documentation on the Android Developers site.
Reading the Accelerometer State
A very interesting input option for games is the accelerometer. All Android devices are required
to contain a three-axis accelerometer. We talked about accelerometers a little bit in Chapter 3.
Generally, we'll only poll the state of the accelerometer.
 
 
Search WWH ::




Custom Search