Example #1
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    //
    float x = event.getX();
    float y = event.getY();

    // If a touch is moved on the screen
    if (event.getAction() == MotionEvent.ACTION_MOVE) {
      // Calculate the change
      float dx = x - oldX;
      float dy = y - oldY;
      // Define an upper area of 10% on the screen
      int upperArea = this.getHeight() / 10;

      if (y < upperArea) {
        // Zoom in/out if the touch move has been made in the upper
        renderer.Zoom(dx * TOUCH_SCALE / 2);
      } else {
        // Rotate around the axis otherwise
        renderer.RotateAnchor(dy * TOUCH_SCALE, dx * TOUCH_SCALE);
      }

      // A press on the screen
    } else if (event.getAction() == MotionEvent.ACTION_UP) {
      // TODO stop the animation
    }

    // Remember the values
    oldX = x;
    oldY = y;

    // We handled the event
    return true;
  }