Touch input

Now that we have seen how to map our hardware buttons, let's dive deeper into the most commonly used input on Android: touch input. However, before we understand touch input, we must understand the coordinate system used to track touches on the screen. Let's take a look at the following illustration to understand this:

Coordinates system in Android

In order to track our touches, we must have a basic understanding of how screen coordinates are mapped on our device. As you can see in the preceding image, our screen's coordinates start from (0,0) at the top-left corner and end at the bottom-right corner with (w,h) where w is the screen ...

Get Learning Android Game Development now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.