Android CS323 Cornez

Lab 12: Games with Touch Gestures



Exercise 1: Build a Touch Gestures App- Bee Finds Finger

  1. When the application is first launched, the user will see a bee element hovering just above a flower located in the upper left corner of the screen.
  2. As the user positions their finger on the screen, the bee will move toward the finger in a proportional easing motion.
  3. As the user moves their finger around the touchscreen, the bee will chase the finger.
  4. When and if the user removes their finger from the screen, the bee will return to the flower.
Drawables:




Exercise 2: Track Fingers in a Multi-touch Gesture

    Create a simple application to handle multiple pointers directly in a multi-touch gesture. The objective of the application is to track two finger pointers as they travel around the screen. As shown in the figure below, the primary pointer is tracked by a large black rectangle. The primary pointer represents the first pointer placed on the screen. The secondary pointer is tracked by a smaller black rectangle.

    As the primary and secondary fingers are placed on the touchscreen, their pointer identifiers are accessed using their pointer data index. These identifiers provide the actual pointer number associated with the MotionEvent data, accounting for individual pointers going up and down since the start of the gesture.

    Once the ACTION_MOVE MotionEvent is triggered, a pointer identifier is used to find the index of its data in the event. Each pointer is tracked by repositioning the rectangle objects at the location of their targeted pointers.

    If either of the pointers is removed from the touchscreen, the fingers are no longer tracked by the rectangles. If only one finger is placed on the touchscreen, as a primary pointer, it will be tracked by the larger rectangle.





Exercise 3: Prey and Predator Game

Create a turn-based game using prey and predator rules.

Drawables: