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

  • Home
  • SEARCH
  • 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 6851647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:16:25+00:00 2026-05-27T01:16:25+00:00

I made this ccTouchBegin method : – (BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event { CGPoint

  • 0

I made this ccTouchBegin method :

- (BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {



    CGPoint location = [touch locationInView:[touch view]];
    location = [[CCDirector sharedDirector] convertToGL:location];

    CGPoint pos = [self getChildByTag:1].position;


    CGSize size = [self getChildByTag:1].contentSize;
    float padding = 3;
    float w = size.width+padding*2;
    float h = size.height+padding*2;

    // first row
    CGRect rect1 = CGRectMake(pos.x-w/2, pos.y-h/2, w/3, h/3);
    CGRect rect2 = CGRectMake(pos.x-(w*(2/3)/2), pos.y-h/2, w/3, h/3);
    CGRect rect3 = CGRectMake(pos.x+(w*(2/3)/2), pos.y-h/2, w/3, h/3);
    //second row
    CGRect rect4 = CGRectMake(pos.x-w/2, pos.y-(h*(2/3)/2), w/3, h/3);
    CGRect rect5 = CGRectMake(pos.x-(w*(2/3)/2), pos.y-(h*(2/3)/2), w/3, h/3);
    CGRect rect6 = CGRectMake(pos.x+(w*(2/3)/2), pos.y-(h*(2/3)/2), w/3, h/3);
    //third  row
    CGRect rect7 = CGRectMake(pos.x-w/2, pos.y+(h*(2/3)/2), w/3, h/3);
    CGRect rect8 = CGRectMake(pos.x-w/2, pos.y+(h*(2/3)/2), w/3, h/3);
    CGRect rect9 = CGRectMake(pos.x-w/2, pos.y+(h*(2/3)/2), w/3, h/3);


    if (CGRectContainsPoint(rect1, location)) {
        NSLog(@"rect1");
    } else if (CGRectContainsPoint(rect2, location)) {
        NSLog(@"rect2");
    } else if (CGRectContainsPoint(rect3, location)) {
        NSLog(@"rect3");
    } else if (CGRectContainsPoint(rect4, location)) {
        NSLog(@"rect4");
    } else if (CGRectContainsPoint(rect5, location)) {
        NSLog(@"rect5");
    } else if (CGRectContainsPoint(rect6, location)) {
        NSLog(@"rect6");
    } else if (CGRectContainsPoint(rect7, location)) {
        NSLog(@"rect7");
    } else if (CGRectContainsPoint(rect8, location)) {
        NSLog(@"rect8");
    } else if (CGRectContainsPoint(rect9, location)) {
        NSLog(@"rect9");
    }

    return YES;
}

its simple, it takes the touch point, and then gets a child’s contentsize and position and divides the place where the child is located to form a 3×3 table. but right now its not working and I am not getting any NSLogs even when I try touching the entire screen. any idea whats wrong?

  • 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-27T01:16:26+00:00Added an answer on May 27, 2026 at 1:16 am
    1. Learn how to set a breakpoint. Breakpoints allow you to instantly test if a method or line of code is being executed or not.
    2. The ccTouchBegan method isn’t called unless you use the CCTargetedTouchHandler as the default handler for touches in your CCLayer. To do this, override registerWithTouchDispatcher in your CCLayer class but don’t call the super implementation:

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

    You do not need to remove the delegate. The CCLayer class handles that for you.

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

Sidebar

Related Questions

I made this method + (CGFloat) round: (CGFloat)f { int a = f; CGFloat
I made this small location class so that I can better handle address information
I made this search method on my Entity Framework repo: public IEnumerable<Person> GetPersonsWithFilter(string filter)
I made this plugin to make the method '[0].click()' cross-browser, but I can not
Made this nice little loop for hiding and showing div's, works as a charm
I made this little Cocoa app with a WebView that displays Google Maps in
I made this code with jQuery to fade images ( but not the one
I made this function to verify a user's twitter credentials. Its running on two
I made this bookmarklet: javascript:(function(){var s=document.createElement('script');s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');document.getElementsByTagName('body')[0].appendChild(s);$('#hldIntMain').hide();$('#fadeBackground').hide();return false;})() Formatted code: // Add in jQuery var
I made this bash one-liner which I use to list Weblogic instances running along

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.