[Solved] CCLayerPanZoom not working

[Solved] CCLayerPanZoom not working
0.0 0


I have added the CCLayerPanZoom to the sample HelloWorld cpp project. The layer 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 had to replace

if ( !CCLayer::init() )
return false;

in helloWorldScene.cpp ’s init() method, with this-

if ( !CCLayerPanZoom::init() )
return false;


Thanks for sharing…


Asloob Qureshi is it possible for you to post the HelloWorldCpp project code? I’m trying to do the same thing with the CCLayerPanZoom but I’m struggling for way to long now. Maybe a look at your code could help me.:slight_smile:


Asloob Qureshi, is it possible you post you helloworldcpp would help us rather, I spent a lot of time to solve it and nothing, hope you can help us, thx :slight_smile:


Hello guys, Sorry for the late reply. I have created a demo android project which uses the CCLayerPanZoom class here [https://github.com/asloobq/cocos2d-x-CCLayerPanZoom]


Still having quiet a bit of trouble with CCLayerPanZoom.

I’ve used a similarly named class in Cocos2d for my use case and it worked very well.

If anyone can help me understand this Cocos2d-x CCLayer, I could really appreciate it.

My use case is that I have a winsize equal to the iPhone and a tilemap that is 3840x3840.

I would like to use CCLayerPanZoom to allow the player to pan (and zoom) the tilemap.

I have not figured out how to make CCLayerPanZoom only show the 3840x3840 and not scroll outside.

There must be some combination of setContentSize, setPanBoundsRect, setPosition that enable this.

I just cannot figure it out even with hours of experimentation :frowning: