Asloob Qureshi wrote:
I have added the CCLayerPanZoom to a sample HelloWorld cpp project. The class HelloWorld is inheriting from the CCLayerPanZoom class. But the pinch zoom / pan is not working. Do I need to do anything more to make this work?
I just bug fixed the problem.
In ccOnTouchesMoved function:
float prevScale = this~~>getScale;
float curScale = this~~>getScale() * ccpDistance(curPosTouch1, curPosTouch2) / ccpDistance(prevPosTouch1, prevPosTouch2);
When you started to move the layer, the calculation of curScale will be wrong. Instead, you could fix the scale like this:
zoomStart = true;
curScale = prevScale;
When zooming is ended, just set zoomStart to false in ccOnTouchEnded.