November 2015
Beginner to intermediate
108 pages
1h 49m
English
If you have never coded a game for a mobile device or tablet, one problem will quickly arise. Unlike for gaming consoles, or even desktops, a distinct lack of input options exist to relay your player’s intentions back into the game code. Without the benefit of game controllers, keyboards, or mice, supplying your player with a complex input system can be difficult.
The majority of your player input will come from the device’s touch screen. Wiring up your game to detect and respond to touch events on the device is not as hard as it may appear on the surface.
Within your GameView class, override the onTouchEvent() as follows:
@Overridepublic boolean onTouchEvent(MotionEvent event) {}
The ...
Read now
Unlock full access