Game Development Reference
In-Depth Information
5.1 Movement
D-Pad
The appearance of the virtual D-Pad in the game is like this (figure 5.1):
Figure 5.1 D-Pad
There're 4 yellow arrows on the D-Pad, by which the player can control the movements of
the main character on the maps.
The 4 yellow arrows stand for 4 directions: DOWN, LEFT, RIGHT, and UP respectively.
The backend thread KeyThread will capture the screen touch events and then call hero's
move() method every 100ms.
Here is the run() method implemented in KeyThread :
public void run(){
while (flag){
while (isGameOn){
if (gv.mDir>-1) {
gv.hero.move(gv.mDir);
}
try {
Thread.sleep(KEY_THREAD_SLEEP_SPAN);
}
catch (Exception e){
e.printStackTrace();
}
Search WWH ::




Custom Search