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 8093251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:27:49+00:00 2026-06-05T20:27:49+00:00

I have a CCLayer containing a number of other CCLayer s (like items of

  • 0

I have a CCLayer containing a number of other CCLayers (like items of text etc). I have another CCLayer to the left hand side with which I want to display thumbnails of a number of these ‘scenes’.

The left hand CCScrollLayer should respond to touches which are within its bounds, while elements in the right hand layer should respond to touches inside their individual bounds.

The problem I’m seeing is that when I drag for example a layer on the right, the CCScrollLayer to the left is responding and scrolling. The elements on the right are unaffected, when I scroll the scroll layer though. It’s as though the CCScrollLayer‘s bounds are too big, which they’re not because I’ve even set them purposely to 100 pixels wide. Is there an unexplained behaviour at work here?

The effect can be seen at http://imageshack.us/photo/my-images/210/dragd.png/

  • 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-05T20:27:51+00:00Added an answer on June 5, 2026 at 8:27 pm

    By default, CCLayer is register as standard touch delegate. You must register it as targeted delegate. In this case CCLayer can claim touch and other touchable elements will not receive it. You can do it by overriding CCLayer method

    -(void) registerWithTouchDispatcher
    {
        [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority: self.priority swallowsTouches:YES];
    }
    

    after this you must replace your delegate methods with these ones

    - (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event;
    @optional
    // touch updates:
    - (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event;
    - (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event;
    - (void)ccTouchCancelled:(UITouch *)touch withEvent:(UIEvent *)event;
    

    your ccTouchBegan:withEvent: method should be like this

    - (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
    {
        BOOL shouldClaimTouch = NO;
        BOOL layerContainsPoint = // check if current layer contains UITouch position
        if( layerContainsPoint )
        {
            shouldClaimTouch = YES;
        }
    
        // do anything you want
    
        return shouldClaimTouch;
    }
    

    just don’t forget to convert touch’s UI coordinates to GL. If this method returns YES, this touch will not be received by any other layer.

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

Sidebar

Related Questions

i have a CCLayer class on top of which i am adding another CClayer
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have a scene created like that: MyScene (subclass of CClayer) .m +(CCScene *)
I have a hierarchy like this: Scene  - gameWorld (CCLayer Z:0)     - player (CCSprite
I have a CCLayer which I need to add a camera to, on top
I have a CCLayer with stuff (sprites, label, etc) on it. This CCLayer is
I am creating a toggle switch. I have a CCScene containing a CCLayer containing
I have 2 CCLayers stacked on top of each other; both are touch enabled.
I am developing a game on Iphone using cocos2d. I have a CClayer containing
I have a CCLayer subclass MyLayer in which I handle touch events: (BOOL) ccTouchBegan:(UITouch

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.