几个星期以来,我一直在使用 CCLayerPanZoom 遇到问题,终于接近了,但仍然有问题。我有一个非常大的 8000 像素 x 8000 像素的平铺地图,我想要的是能够放大到大约 2.0f 并缩小到大约 0.4f。下面的代码很好用,它让我可以平移整个瓦片地图,而不是平移到边缘——CCLayerPanZoom 的一个常见问题,但是代码不允许放大或缩小。我现在已经注释掉了 minScale 和 maxScale,因为它们都不起作用。我尝试更改 minScale 和 maxScale 的位置,但它在任何地方都不起作用。有谁知道如何让 minScale 和 maxScale 工作以便缩放起作用?
//PanZoomLayer
_panZoomLayer = [[CCLayerPanZoom node] retain];
[self addChild: _panZoomLayer];
_panZoomLayer.delegate = self;
[_panZoomLayer addChild: _tileMap z :1 tag: kBackgroundTag];
_panZoomLayer.mode = kCCLayerPanZoomModeSheet;
_panZoomLayer.rubberEffectRatio = 0.0f;
CCNode *backgroundZ = [_panZoomLayer getChildByTag: kBackgroundTag];
CGRect boundingRect = CGRectMake(0, 0, 0, 0);
boundingRect.size = [backgroundZ boundingBox].size;
[_panZoomLayer setContentSize: boundingRect.size];
_panZoomLayer.anchorPoint = ccp(0.5f, 0.5f);
_panZoomLayer.position = ccp(0.5f * winSize.width, 0.5f * winSize.height);
_panZoomLayer.panBoundsRect = CGRectMake(0, 0, winSize.width, winSize.height);
_panZoomLayer.minScale = 0.4f;
_panZoomLayer.maxScale = 2.0f;
//end PanZoomLayer