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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:08:54+00:00 2026-05-15T22:08:54+00:00

I Have the following code: -(void) changeAnimation:(NSString*)name forTime:(int) times { if(currentAnimation != @attack) {

  • 0

I Have the following code:

-(void) changeAnimation:(NSString*)name forTime:(int) times {
 if(currentAnimation != @"attack")
 {
  id action = [CCAnimate actionWithAnimation:[self animationByName:name]];
  id repeatAction = [CCRepeat actionWithAction:action times:times];
  currentAction = [self runAction:repeatAction];
  lastANimation = currentAnimation;
  currentAnimation = name;
 }
 else if(currentAction.isDone)
 {
   //Here is where I would change the animation
   //but I commented the code for now
 }
}

So when I run this and click on the button that changes the animation to “attack” (by calling [mysprite changeAnimation:@”attack” forTime:1];), I get a EXC_BAD_ACCESS error from the “currentAction.isDone” line, the next time the function is called (the joystick will call changeAnimation to try and change the animation to “run” or “idle”, but I want the attack animation to finish first). Any thoughts on whyI get this? currentAction is declared in my class.

Edit: there is nothing in the rest of the class that interacts with currentAction, beside a getter. Its declaration is in the .h (CCAction* surrentAction). Do I need to initialize it? I thought the returned value from runAction would be sufficient? ANyways, when I run the debugger, it is not nil, and assigned to the correct action.

Thanks,

Dave

Edit:
I ended up creating a sequence when “attacking” that calls a function that changes the currentAnimation, so i avoided the issue. Still no idea what was happening.
Here’s the answer if your interested:
Other Post

  • 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-15T22:08:55+00:00Added an answer on May 15, 2026 at 10:08 pm

    More of the class is probably needed to really answer this properly, but the EXC_BAD_ACCESS typically happens because you’re accessing something that has been released and is no longer available in memory.

    I’m guessing that somewhere in your class you’re releasing, either explicitly, or implicitly, the “currentAction” object asynchronously – and when you’re checking later, it’s done & gone and you’re hitting this crasher.

    In general, keeping a state variable or two that you always have known values on is a good way to go, and for the “actions” that you’re going through, if they’re asynchronous and doing their own memory management, leave them as such and work through some state variables that you maintain and control all the memory management around. It’s a pretty reasonable pattern for asynchronous callbacks, either with the classic stuff or as you move into using blocks with iOS 4.0

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

Sidebar

Related Questions

I currently have the following code: -(void) inputNumber:(int)number { NSString *str; str = [NSString
I have following code: public static void ProcessStep(Action action) { //do something here if
i have following pseudo code : void siftup(int n) pre condition n>0 && heap(1,n-1)
I have the following code: void Foo() { static std::vector<int>(3); // Vector object is
I have the following code -(void) animate:(UIButton*) b withState: (int) state andLastState:(int) last_state {
I have the following code: void set_fl(int fd, int flags) /* flags are file
SO I have the following code public void rand(int N){ double[]x=new double[N]; double[]y=new double[N];
I have the following code: - (void)downloadPressed:(id)sender { [_download startDownloadWithParser:^id(NSData *rawData) { NSString* downloadName
I have the following code: void ThreadMethod() { Console.WriteLine(Thread..); } IAsyncResult actionResult; Action a
I have the following code: void readFile(BST *tree) { ifstream infile(input.txt); long int sid,

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.