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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:20:40+00:00 2026-05-16T10:20:40+00:00

Friends i am new to cocos2d programming and Mac in general! I have noticed

  • 0

Friends i am new to cocos2d programming and Mac in general!

I have noticed this EXC_BAD_ACCESS errors ruining most of my time… Take the following snippet of code from the Geek & Dad’s tutorial…

-(void) AddEnemyAtX:(int)x Y:(int)y {
    CCSprite *enemy1 = [CCSprite spriteWithFile:@"enemy1.png"];
    enemy1.position = ccp(x,y);
    [self addChild:enemy1];
    [self animateEnemy:enemy1];
    NSLog(@"%@", enemy1);
}

-(void) animateEnemy:(CCSprite *)enemy {
    ccTime actualDuration = .5;
    id actionMove = [CCMoveBy actionWithDuration:actualDuration
           position:ccpMult(ccpNormalize(ccpSub(_player.position,enemy.position)), 10)];
    id actionFinished = [CCCallFunc actionWithTarget:self
           selector:@selector(animateEnemyFinished:)];
        [enemy runAction:[CCSequence actions:actionMove,actionFinished,nil]];
}

-(void) animateEnemyFinished:(id)sender {
    CCSprite *enemy = (CCSprite *)sender;
    [self animateEnemy:enemy];
}

here _player is a global variable and accessible everywhere, I call AddEnemyAtX: Y: and pass some coordinates. My problem is the first time the loop runs fine… But again when the control is passed from animateEnemyFinished to animateEnemy then the app crashes mentioning “EXC_BAD_ACCESS”!

From what i figured out, the Sprite reference is not passed correctly! Help!

  • 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-16T10:20:41+00:00Added an answer on May 16, 2026 at 10:20 am

    Wow!!
    Atlast figured it out…

    A small mistake… just replacing the line

    id actionFinished = [CCCallFunc actionWithTarget:self
               selector:@selector(animateEnemyFinished:)];
    

    with

    id actionFinished = [CCCallFuncN actionWithTarget:self
               selector:@selector(animateEnemyFinished:)];
    

    did the trick! What i understood from this was that @selector() passes the id of the object which called upon it but at the same time when we use it along with CCCallFuncN it passes the id of the Node just parent to the object which called upon it!

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

Sidebar

Related Questions

I'm about to start a new django project with friends. This project includes a
my dear Friends I am new to this java ..so plz help me thank
Hii friends, i m new to iphone development and i have gone through some
I have two professional programmer friends who are going to teach me, and they
I have a database table that i want to allow my friends to update.
What Facebook API call should I make in order to find new friends by
Example: I have a list of friends which I retrieve as XML from a
On a social network I am working on in PHP/MySQL, I have a friends
Consider this example (typical in OOP books): I have an Animal class, where each
friends I am new in game development programing .And I want to understand the

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.