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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:59:26+00:00 2026-05-24T15:59:26+00:00

My problem is that I didn’t find a solution to pierce through a UIScrollView

  • 0

My problem is that I didn’t find a solution to “pierce” through a UIScrollView so the ccLayer could recognize the ccTouch events

   self.isTouchEnabled = YES;
    [[NSBundle mainBundle] loadNibNamed:@"myLayer" owner:self options:nil];

…

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

-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
        CGPoint location = [self convertToWorldSpace:[self convertTouchToNodeSpace:touch]];

Any ideas how to create a delegate or another solution to bypass the UI and talk with the cc?

  • 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-05-24T15:59:27+00:00Added an answer on May 24, 2026 at 3:59 pm

    I had this problem this morning with Cocos2D v1.0.0. My solution was to include the CCTouchDispatcher method call inside my init method for the layer, and then that layer, inside a UIView, would recognize touches.

    -(id) init
    {
      if ((self = [super init]) != nil) {
        // do stuff
        [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
      }
      return self;
    }
    
    -(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
    {
      CGPoint location = [self convertToNodeSpace:[[CCDirector sharedDirector] convertToGL:[touch locationInView:[touch view]]]];
      NSLog(@"TouchBegan at x:%0.2f, y:%0.2f", location.x, location.y);
    
      return YES;
    }
    

    An alternative solution would be to use the ccTouchesBegan method:

    -(id) init
    {
      if ((self = [super init]) != nil) {
        // do stuff
        self.isTouchEnabled = YES;
      }
      return self;
    }
    
    
    -(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {   
      for (UITouch *thisTouch in touches) {
        CGPoint location = [self convertToNodeSpace:[[CCDirector sharedDirector] convertToGL:[thisTouch locationInView:[thisTouch view]]]];
        NSLog(@"TouchesBegan at x:%0.2f, y:%0.2f", location.x, location.y); 
      }
    }
    

    Note that the two touch methods have different methods to let your application know it should respond to touches. You can’t mix and match how you want to respond to touches, and which touches you want to observe.

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

Sidebar

Related Questions

One problem that I come across regularly and yet don't have a solution to
He're an interesting problem that looks for the most Pythonic solution. Suppose I have
I have a strange problem that i didn't encounter before i must mention that
A problem that we need to solve regularly at my workplace is how to
The problem that I am having has to do with the need to keep
A problem that has frequently come up in my career is I have some
Simple problem that I can't figure out... How can I print a '%' character
I have a problem that confuses my users, being that although an item is
This has been a problem that I haven't been able to figure out for
I have the problem that an specific step in Ant can only be executed

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.