Home > other >  Cocos2dx - Android map zoom computing offset the origin to the upper left corner
Cocos2dx - Android map zoom computing offset the origin to the upper left corner

Time:09-17

Cocos2dx - Android map zoom calculated offset the origin to the upper left corner, written in coco2d - Android version in a map, two refers to the scale, has been to the top left corner origin offset in the past, the normal map two fingers scaling, should be in the middle, has been for less than the current screen shows neutral position, don't know whether I transform the world coordinate errors, or how to return a responsibility

/* *
* have two finger moves on the screen, state for zoom zoom in
* refers to the operation more fingers shaking to screen dithering
*
* @ param event
*/
Public void handleMultiTouch (MotionEvent event) {
MFingerDis=distanceBetweenFingers (event);
Float fingersScale=(float) (distanceBetweenFingers (event)/lastFingerDis);


If (Math. Abs (mFingerDis - lastFingerDis) & gt; 5) {
If (mFingerDis & gt; LastFingerDis) {
If (getScale () & lt; SCALE_MAX_NUM) {
//to get 2 midpoint coordinates to zoom in
Enclosing setScale (getScale () * fingersScale);
LastFingerDis=mFingerDis;
}

} else {
//scaling of less than 1 times stop zoom
If (getScale () & gt; SCALE_MIX_NUM) {
Enclosing setScale ((getScale () * fingersScale));
}
LastFingerDis=mFingerDis;
}
}
}



Enclosing setScale ((getScale () * fingersScale)); Pure zoom ratio zoom, zoom effects, offset the upper left corner
  • Related