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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:26:23+00:00 2026-06-18T10:26:23+00:00

I am trying to figure out touch handling on multiple CCNode s . I

  • 0

I am trying to figure out touch handling on multiple CCNodes .

I have

 Main CCLayer
            ------> z:2 Hud CCNode

On main layer I choose an object, on hud layer I want to control it. I followed this q&a its very helpful Cocos2d handling touch with multiple layers

On Main Layer touch events, below is Hud Node work:

-(void) registerWithTouchDispatcher
{
   [[CCDirector sharedDirector].touchDispatcher addTargetedDelegate:self priority:0 swallowsTouches:YES]; 
}
-(BOOL) ccTouchBegan:(UITouch*)touch withEvent:(UIEvent*)event
{
    //detects touched Object and sends it to hud 

    if (object != nil)
    {
        //sends it to hud
        return true;
    }

    return false;
}
-(void) ccTouchMoved:(UITouch*)touch withEvent:(UIEvent*)event

-(void) ccTouchEnded:(UITouch*)touch withEvent:(UIEvent*)event

-(void) ccTouchCancelled:(UITouch*)touch withEvent:(UIEvent*)event

On Hud CCNode none of ccTouchBegan/moved/ended methods are fired

-(void) registerWithTouchDispatcher
{
  [[CCDirector sharedDirector].touchDispatcher addTargetedDelegate:self priority:0 swallowsTouches:YES];

}
-(BOOL) ccTouchBegan:(UITouch*)touch withEvent:(UIEvent*)event
{
    if (object!=nil) {
        NSLog(@"Touch began");
        return YES;
    }
    else
        return NO;
}

EDIT:
I have a button to set speed of the object on HUD Node , it has nothing to do with object!=nil because when I put breakpoints I see that -(BOOL) ccTouchBegan:(UITouch*)touch withEvent:(UIEvent*)event is never called

-(void)speed1Tapped:(id)sender
{
    if (object!=nil) {
        NSLog(@"Moving Object is %@:",object!=nil);
     }
}
On Log I get:
object is <ObjectATC: 0x13763850>

Why ccTouchBegan/moved/ended methods are not fired in CCNode?

How can I handle touches on multiple CCNodes, CCLayers ?

  • 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-18T10:26:24+00:00Added an answer on June 18, 2026 at 10:26 am

    I guess you dont receive touch method because you did not register the touchDipatcher

    either in your CCNodes init method or onEnter method try to register it.

    //register touches
    - (void)onEnter {
        [[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
        [super onEnter];
    }
    
    - (void)onExit {
        [[[CCDirector sharedDirector] touchDispatcher]removeDelegate:self];
        [super onExit];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

trying to figure out why this is happening - I have an input text
I am trying to figure out how to select an object first then I
I have been had a tough time trying to figure this out. Let me
I'm trying to figure out how to make use of the pinch touch effect
I have been trying to figure out how to forward the touches from a
I'm trying to figure out how best to do this, I have a map
Trying to figure out how I can do this properly. The print_r looks like
Trying to figure out why my silverlight app suddenly just displays nothing (right click
Trying to figure out how to type (via events not set the value) on
Trying to figure out a regex for validating a network path ie: \\comp\xyz or

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.