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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:27:19+00:00 2026-06-18T02:27:19+00:00

After making adjustments to my code as suggested, my animation now works. Now, I’d

  • 0

After making adjustments to my code as suggested, my animation now works. Now, I’d like to ask how to reverse the movements of the sprite. I am trying to make the sprite move as if the wind is blowing in it. Here’s my code now:

-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super's" return value
if( (self=[super init]) ) {
    CGSize winSize = [[CCDirector sharedDirector] winSize];
    self.isTouchEnabled = YES;

    CCSprite *black = [CCSprite spriteWithFile:@"b.png"];
    black.position = ccp(100, 160);
    black.scaleX = 100 / black.contentSize.width;
    black.anchorPoint = ccp(0.03, 0);

    CCSpriteFrameCache *frame = [CCSpriteFrameCache sharedSpriteFrameCache];
    [frame addSpriteFramesWithFile:@"bLongAnimation.plist"];
    CCSpriteBatchNode *bHair = [CCSpriteBatchNode batchNodeWithFile:@"bLongAnimation.png"];
    [self addChild:bHair];

    [self addChild:black z:1 tag:1];

    //Animation
    NSMutableArray *animateBlackHair = [NSMutableArray arrayWithCapacity:10];
    for (int i = 1; i < 10; i++)
    {
        NSString *animBlackHair = [NSString stringWithFormat:@"b%i.png", i];
        CCSpriteFrame *blackFrame = [frame spriteFrameByName:animBlackHair];
        [animateBlackHair addObject:blackFrame];

        //I added this code block thinking it might work
        for(i = 10; i > 1; i--)
        {
            NSString *revAnimation = [NSString stringWithFormat:@"bRightLong%i.png", i];
            CCSpriteFrame *revFrame = [frame spriteFrameByName:revAnimation];
            [animateBlackHair1 addObject:revFrame];
        }
    }
    CCAnimation *blowHair = [CCAnimation animationWithSpriteFrames:animateBlackHair delay:0.1];
    CCAction *blowingHair = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:blowHair]];
    [black runAction:blowingHair];        
}
return self;}

My guess didn’t work so I was wondering how I can reverse the movements as soon as it finishes the first one?

UPDATE: Never mind, I figured it out. I just moved the for loop for reversing the action outside of the other loop. Thank you for the 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-06-18T02:27:20+00:00Added an answer on June 18, 2026 at 2:27 am

    Try setting the delay on the animation to something other than 0. Try 0.1 or 0.4 or something. If you set it to zero I don’t think the animation runs, and if it does, it runs too fast to be visible.

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

Sidebar

Related Questions

I'm now making unit-tests for already existing code. I faced the next problem: After
After making cabal install of the darcsden code I get this message: cabal: The
I pushed my app to heroku after making sure it works fine in my
I deploy my J2EE application after making some changes to the code. At maximum
I'm trying to write a simple SOAP client using SOAP::Lite . After making a
I am trying to save a file using DialogResult and StringBuilder . After making
After making some research, I now know that I can launch an iphone app
I would like my application after making it five calculations. That is, using 5
Can I refresh the whole page after making ajax calls. kindly check my code
Can I call doClick on a button after making it invisible. like: StopBtn.setVisible( false

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.