Game Development Reference
In-Depth Information
MultiTouchGesture
MultiTouchGesture is a class that encapsulates a gesture type such as a character move or
look (see Listing 2-8). It also defines the bounds on the screen where this gesture is valid (by
using the Rect Android class). When the gesture is valid, it will execute some action (sending
the move or look increments to the native engine, for example).
Listing 2-8. MultiTouchGesture
package com.touch;
import android.graphics.Point;
import android.graphics.Rect;
import android.view.MotionEvent;
public class MultiTouchGesture {
public enum eGestureType { MOVE, LOOK };
Rect bounds;
eGestureType type;
public MultiTouchGesture(eGestureType type, Rect bounds) {
this.type = type;
this.bounds = bounds;
}
/**
* Execute gesture
* @param action
* {@link MotionEvent} action: ACTION_UP, ACTION_MOVE,...
* @param p
* Finger point XY coordinates
*/
public boolean execute(int action, Point p) {
switch (type) {
case MOVE:
doMove(action, p);
break;
case LOOK:
doLook(action, p);
break;
default:
break;
}
return true;
}
 
Search WWH ::




Custom Search