Game Development Reference
In-Depth Information
How it works...
The g_Responder instance receives all the data about decoded gestures.
Implementing an on-screen joypad
It is time to make use of the multi-touch facilities and emulate a gaming console-like interface
on an Android device touch screen.
Getting ready
Learn how to handle multi-touch input from recipes Processing multi-touch events on Android
and Processing multi-touch events on Windows before proceeding with this recipe.
How to do it...
We implement a custom multi-touch event handler, which keeps track of all the touch points.
The joystick is rendered as a full-screen bitmap shown on the left-hand side. When the user
touches the screen, we use the touch coordinates to fetch the pixel color from the mask on
the right-hand side of the igure. Then, we ind the internal button corresponding to the color
and change its Pressed state. The following igure shows the joypad visual representation
and the color mask:
1.
Single button of our virtual joystick is determined by its color in the mask and the
index in the buttons table:
struct sBitmapButton
{
vec4 FColour;
int FIndex;
};
 
Search WWH ::




Custom Search