objective-ccocos2d-iphoneccscrolllayer

CCScrollLayer issues in cocos2d


i am having this problem try to use the cocos2d CCScrollLayer

I have added the CCScrollLayer classes to my scene, and having this 3 problems: 1. it is not get touches 2.it puts the backgrounds (landscape) one on each other, like this: page1 is in place,but page2 is in top of half screen,so i see half page1 half page2. 3. the dotes in the buttom that show on which page i am right now- can i eliminate them,or move them to other place ?

thanks a lot.

code:

CGSize screenSize = [CCDirector sharedDirector].winSize;
        // PAGE 1
        CCLayer *page1 = [[CCLayer alloc] init];
        BACK.position=ccp(screenSize.width/2 ,screenSize.height/2);
         [page1 addChild:BACK];
        // PAGE 2
        CCLayer *page2 = [[CCLayer alloc] init];
        BACK1.position=ccp(screenSize.width/2,screenSize.height/2);
        [page2 addChild:BACK1];
        // PAGE 3
        CCLayer *page3 = [[CCLayer alloc] init];
        BACK1.position=ccp(screenSize.width/2,screenSize.height/2);
        [page3 addChild:BACK2];

        CCScrollLayer *scroller = [[CCScrollLayer alloc] initWithLayers:[NSMutableArray arrayWithObjects: page1,page2, nil] widthOffset: 230];

        // finally add the scroller to your scene
        [self addChild:scroller];

and the source of the classes:


Solution

  • Answers to your three questions:

    1. Put a breakpoint in CCScrollLayer's ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event to make sure it isn't receiving touches.
    2. CCScrollLayer overlaps the layers intentionally. If you want just one layer on the screen at a time, increase the scrollWidth_ property's value of CCScrollLayer. Otherwise, you're going to have to shrink your background images so they don't overlap.
    3. I suggest editing the CCScrollLayer class to remove or move the dots.