Reading Player Input
If this is your first time coding a game for a mobile device or tablet, you are likely to quickly notice that there is a distinct lack of input options to relay your player’s intentions back into the game code. Without the benefit of game controllers, keyboards, or mice, it can be very hard to supply your player with a complex input system.
Wiring up your game to detect and respond to touch events on the device is not as hard as it might appear on the surface.
Let’s take a look at some of the more common problems in using a touch screen as a game input.
5.1 Detect a Screen Touch
Your game is unable to detect when the player has touched the screen.
Use the onTouchEvent() to detect where and ...