title: How to code for multitouch
body: <p>So I'm developing an application that must handle multitouch.  Basically I want single touch for rotating ( this is no problem ).  And multitouch for scrolling.</p>
  
  <p>I have the basic code in, but I'm having problems when the shift from single to multitouch, and vice verca, occur.  Basically the movement will jolt because the median position of the multitouch ( two fingers ) and the absolute position of the single finger are at a distance.  So if I have two fingers on the screen, they make up a median position, and then lift one finger, it would be like a quick movement from that median position to the absolute single finger position.  This will be the movement that I don't want.</p>
  
  <p>This is my code:</p>
  
  <pre><code>@Override
  public boolean onTouchEvent( MotionEvent event ) {
      float xEvent[] = new float[ 2 ];
      float yEvent[] = new float[ 2 ];
      switch( event.getPointerCount() ) {
          case 1:
              xEvent[ 0 ] = event.getX( 0 );
              yEvent[ 0 ] = event.getY( 0 );
              switch( event.getAction() ) {
                  case MotionEvent.ACTION_DOWN:
                      camera.onTouchDown( xEvent[ 0 ], yEvent[ 0 ] );
                      return true;
                  case MotionEvent.ACTION_MOVE:
                      camera.onTouchRotate( xEvent[ 0 ], yEvent[ 0 ] );
                      return true;
                  default: return super.onTouchEvent( event );
              }
          case 2:
              xEvent[ 0 ] = event.getX( 0 );
              yEvent[ 0 ] = event.getY( 0 );
              xEvent[ 1 ] = event.getX( 1 );
              yEvent[ 1 ] = event.getY( 1 );
              switch( event.getAction() ) {
                  case MotionEvent.ACTION_DOWN:
                      camera.onTouchDown( ( ( xEvent[ 0 ] + xEvent[ 1 ] ) / 2 ), ( ( yEvent[ 0 ] + yEvent[ 1 ] ) / 2 ) );
                      return true;
                  case MotionEvent.ACTION_MOVE:
                      camera.onTouchSlide( ( ( xEvent[ 0 ] + xEvent[ 1 ] ) / 2 ), ( ( yEvent[ 0 ] + yEvent[ 1 ] ) / 2 ) );
                      return true;
                  case MotionEvent.ACTION_POINTER_1_UP:
                      camera.onTouchDown( xEvent[ 1 ], yEvent[ 1 ] );
                      return true;
                  case MotionEvent.ACTION_POINTER_2_UP:
                      camera.onTouchDown( xEvent[ 0 ], yEvent[ 0 ] );
                      return true;
                  default: return super.onTouchEvent( event );
              }
          default: return false;
      }
  }
  </code></pre>
  
  <p>The onTouchDown function of the camera just sets the first value of the touch move.  That's why I also use it in the up movement to set a new begin value for the single touch movement when coming from a multitouch.</p>
  
  <p>I hope someone knows what my problem is and can help me further.</p>