1

指を離してもう一度置くと、ズームが飛び回ります!誰も問題を知っていますか?

boolean surfaceTouchEvent(MotionEvent event) {
  pointNum=event.getPointerCount();
  switch (event.getAction() & MotionEvent.ACTION_MASK) {
  case MotionEvent.ACTION_POINTER_DOWN:
    // User is pressing down another finger.
    float x11 = event.getX(0) - event.getX(1);
    float y22 = event.getY(0) - event.getY(1);
    z4 = sqrt(x11*x11+y22*y22);

    break;
  case MotionEvent.ACTION_POINTER_UP:
    // User is released one of the fingers.
    break;
  case MotionEvent.ACTION_MOVE:
    if (pointNum >= 2 ) {
      x1=event.getX(0);
      x2=event.getX(1);
      y1=event.getY(0);
      y2=event.getY(1);

      float x = event.getX(0) - event.getX(1);
      float y= event.getY(0) - event.getY(1);
      float z3 = sqrt(x*x+y*y);
      if (pointNum >= 2 ) {
        if ( z3 < z4 ) {
          zoom = z3/z4;
        }
        else {
          zoom = z3/z4;
        }
        zoom = constrain(zoom, 0, 100);
      }
      press1=event.getSize(0);
      press2=event.getSize(1);
    }
    break;
  }
  return super.surfaceTouchEvent(event);
}
4

0 に答える 0