android zoom jump around !
in
Android Processing
•
1 year ago
when I zoom without removing my finger it's ok but when I remove my finger and put it to zoom in it jumps , In other word you could not zoom if you remove your finger and again put it there !
what's the problem ? please help!
- float zoom ;
- void setup(){
- }
- void draw(){
- scale(zoom);
- }
- .
- .
- .
- 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;
- }
1