Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7848297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:09:11+00:00 2026-06-02T18:09:11+00:00

I am trying to get CCScrollLayer to work in my cocos2d app, but it

  • 0

I am trying to get CCScrollLayer to work in my cocos2d app, but it won’t scroll.

Here is what I did:

  1. Using the cocos2d template, created a iOS cocos2d project. Added the CCScrollLayer files, and imported into my HelloWorldLayer class. Added a method “layerWithLevelName” to create the layers.

  2. In init, I created a few layers for testing. Below is the code for my HelloWorldLayer implementation. It is very basic, as I am just trying to get some layers to scroll.

#

// HelloWorldLayer implementation
#import "HelloWorldLayer.h"
#import "CCScrollLayer.h"
@implementation HelloWorldLayer


+(CCScene *) scene
{
    CCScene *scene = [CCScene node];    
    HelloWorldLayer *layer = [HelloWorldLayer node];    
    [scene addChild: layer];

    // return the scene
    return scene;
}

-(CCLayer*) layerWithLevelName:(NSString*)name number:(int)number screenSize:(CGSize)screenSize
{
    CCLayer *layer = [[[CCLayer alloc] init]autorelease];

    int largeFont = [CCDirector sharedDirector].winSize.height / 9;
    CCLabelTTF *layerLabel = [CCLabelTTF labelWithString:name fontName:@"Marker Felt" fontSize:largeFont];
    layerLabel.position =  ccp( screenSize.width / 2 , screenSize.height / 2 + 10 );
    layerLabel.rotation = -6.0f;
    layerLabel.color = ccc3(95,58,0);
    [layer addChild:layerLabel];

    return layer;
}

// on "init" you need to initialize your instance
-(id) init
{
    // always call "super" init
    // Apple recommends to re-assign "self" with the "super" return value
    if( (self=[super init])) 
    {

        // ask director the the window size        
        NSMutableArray* _layers = [[NSMutableArray alloc]init];
        CGSize screenSize = [CCDirector sharedDirector].winSize;  

        for (int i=0; i<3; i++)
        {
            int number = i;
            NSString* name = [[NSString alloc]initWithFormat:@"level%d",i];
            CCLayer* layer = [self layerWithLevelName:name number:number screenSize:screenSize];
            [_layers addObject:layer];

            [name release];
        }

        // Set up the swipe-able layers
        CCScrollLayer *scroller = [[CCScrollLayer alloc] initWithLayers:_layers 
                                                            widthOffset:230];
        [self addChild:scroller];
//        [scroller selectPage:0];

        [scroller release];
        [_layers release];

    }
    return self;
}

- (void) dealloc
{
    [super dealloc];
}
@end

If you run the code, you will find that you can see the levels / scroll layer –> It seems to have loaded properly. But you can’t scroll. What have I forgotten to do? What am I doing wrong?

EDIT: I am using cocos2d-iphone 1.1beta2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:09:13+00:00Added an answer on June 2, 2026 at 6:09 pm

    It seems that this is an issue with 1.1beta2.

    A temporary workaround is to set scroller.stealTouches = NO;

    I don’t know what other side effects this has though.

    EDIT:

    Fix: Use updated CCTouchDispatcher files:

    https://github.com/cocos2d/cocos2d-iphone/blob/develop/cocos2d/Platforms/iOS/CCTouchDispatcher.m
    and corresponding .h file
    https://github.com/cocos2d/cocos2d-iphone/blob/develop/cocos2d/Platforms/iOS/CCTouchDispatcher.h

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying get Struts 2 and Tiles to work and I am using
Hi am trying get GPS using network provider and GPS provider. but am getting
Trying to get a tab character into a JMenuItem using \t but it's not
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
Trying to get a JSON output to work with jqGrid 'userdata' option. The example
trying to get my head around Feedzirra here. I have it all setup and
I'm trying get only the Saturdays and Sundays between two dates, but I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.