CCScrollLayer and CCScrollLayerButton usage

Hi all , I’m trying to create horizontal and vertical scroll and I got a problem ,

I got some questions with the usage of CCScrollLayer and CCScrollLayerButton :

  1. How to change the CCScrollLayer size ? ( currently scrollable area is the entire screen )
  2. How make the scroll vertical ?

thx for all reply

best regards

i write this cpp to extend CCScrollLayer

it have scroll indicator of vertical and horizontal.

sorry my english is poor!

try it,hope it will be useful for you.

Thanks for your reply 小 苏

and Thank You very much for sharing your extended class

:slight_smile:

glEnable(GL_SCISSOR_TEST);

glScissor(clipRect.origin.x,clipRect.origin.y,clipRect.size.width,clipRect.size.height);
CCLayer::visit();//< Will draw after glPopScene.

glDisable(GL_SCISSOR_TEST);

小 苏 wrote:

i write this cpp to extend CCScrollLayer
>
it have scroll indicator of vertical and horizontal.
>
sorry my english is poor!
>
try it,hope it will be useful for you.

CCMutableArray<CCLayer*> layers;
layers.addObject(layer1);
layers.addObject(layer2);
layers.addObject(layer3);
layers.addObject(layer4);
layers.addObject(layer5);

CCScrollLayer* pScrollLayer = CCScrollLayer::layerWithLayers(&layers, 0);
pScrollLayer->setPosition(ccp(0,0));
addChild(pScrollLayer);

i used the above code for CCScrollLayerButton and CCScrollLayer, but what we have to use CCScrollLayerEX code.

The CCScrollLayerExt is not working as expected…
I just create a new Layer as:
@
ScrollLayerExt *scroll = new ScrollLayerExt(CCRect::CCRectMake(0,0,960,640));
this->addChild(scroll);
@

It adds a gray colored layer to the screen but when I swipe on the screen, the layer comes back to the original place after I leave it , even though I have not reached the end of the layer. Any help is appreciated.

Thanks.

Nidhi Ajwani wrote:

The CCScrollLayerExt is not working as expected…
I just create a new Layer as:
@
ScrollLayerExt *scroll = new ScrollLayerExt(CCRect::CCRectMake(0,0,960,640));
this->addChild(scroll);
@
>
It adds a gray colored layer to the screen but when I swipe on the screen, the layer comes back to the original place after I leave it , even though I have not reached the end of the layer. Any help is appreciated.
>
Thanks.

I am having some issues with Creating a CCScrollLayerButton, assigning a tag to it then reading that tag in my callback function.
when i try and get the tag i am getting an EXEC_BAD_ACCESS exception.
I doing the following:

CCScrollLayerButton* levelButton = CCScrollLayerButton::buttonWithFile( “CompleteLevel.png”, this, menu_selector(LevelSelectionScene::callfunc));
levelButton~~>node~~>setTag;
levelButton~~>setAnchorPoint);
levelButton~~>setPosition(GetLevelPosition(3));
layer~~>addChild;
and the callFunc looks as follows:

void LevelSelectionScene::callfunc
{
int tagNum = pSender~~>getTag();
}

any help would be much appreciated.

CCScrollLayerExt::setContentLayerSize(CCSize mSize) can set the size for scroll layer!
so you had to set the right size for it.

Does anybody have CCScrollLayer class ported to cocos2d-x v2.xx ?

“Does anybody have CCScrollLayer class ported to cocos2d-x v2.xx ?” :joy: