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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:01:11+00:00 2026-05-30T22:01:11+00:00

well I have a problem with my code : – (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

  • 0

well I have a problem with my code :

- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch* myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView: [myTouch view]];
location = [[CCDirector sharedDirector]convertToGL:location];
CGRect MoveableSpriteRect =CGRectMake(oeuf1.position.x -(oeuf1.contentSize.width/2),oeuf1.position.y-(oeuf1.contentSize.height/2),oeuf1.contentSize.width,oeuf1.contentSize.height);

if (CGRectContainsPoint(MoveableSpriteRect, location)) {
    [self removeChild:oeuf1 cleanup: YES];
    [self removeChild:ombreOeuf1 cleanup: YES];
}
}

When I touch oeuf1 it disappear like I wanted but then if i touch the screen again my app crash I don’t know why ? how can I solve this please ? thank you . Sorry for my english I’m french :/

  • 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-30T22:01:13+00:00Added an answer on May 30, 2026 at 10:01 pm

    The line CGRect MoveableSpriteRect =CGRectMake(oeuf1.position.x -(oeuf1.contentSize.width/2),oeuf1.position.y-(oeuf1.contentSize.height/2),oeuf1.contentSize.width,oeuf1.contentSize.height); is still referencing oeuf1 once it has been removed, and so will cause an EXC_BAD_ACCESS error. The simplest way to fix it is to declare a BOOL in your header file, and set it to YES/true when you remove oeuf1 and ombreOeuf1. Then if the BOOL is true, don’t run

    CGRect MoveableSpriteRect =CGRectMake(oeuf1.position.x -(oeuf1.contentSize.width/2),oeuf1.position.y-(oeuf1.contentSize.height/2),oeuf1.contentSize.width,oeuf1.contentSize.height);
    
    if (CGRectContainsPoint(MoveableSpriteRect, location)) {
        [self removeChild:oeuf1 cleanup: YES];
        [self removeChild:ombreOeuf1 cleanup: YES];
    }
    

    EDIT:

    In your .h file add:

    @interface .... {
        ...
        BOOL oeuf1Removed; // Feel free to translate this to French!
    }
    

    And then change -touchesBegan to:

    - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch* myTouch = [touches anyObject];
        CGPoint location = [myTouch locationInView:[myTouch view]];
        location = [[CCDirector sharedDirector] convertToGL:location];
        if (!oeuf1Removed) {
            CGRect MoveableSpriteRect = CGRectMake(oeuf1.position.x -(oeuf1.contentSize.width/2),oeuf1.position.y-(oeuf1.contentSize.height/2),oeuf1.contentSize.width,oeuf1.contentSize.height);
    
            if (CGRectContainsPoint(MoveableSpriteRect, location)) {
                [self removeChild:oeuf1 cleanup: YES];
                [self removeChild:ombreOeuf1 cleanup: YES];
                oeuf1Removed = YES;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well i have this code to find the paint quality of a room. void
Well im here because i have a problem. i have code that was created
Well i have the following code: <?php while(1==1){ echopiece<br>; flush(); }; ?> The problem
I have recently tried a problem,my code run well on the cases it presented
well i have most probably an extremly stupid problem but could not figure it
I have a problem with debugging sessions. My program executes very well in a
Well here's my problem I have three tables; regions, countries, states. Countries can be
I have the following problem that the standard library doesn't solve well, and I'm
Well, I have a really small problem. How can I access an ASP.NET Drop
I have problem with code. I have written a function for extracting a parameter,

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.