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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:55:02+00:00 2026-06-11T20:55:02+00:00

I am currently learning cocos2D-x and am doing some sprite animation. My Objective is

  • 0

I am currently learning cocos2D-x and am doing some sprite animation.
My Objective is that when a button is clicked the object moves to left with some animation.
Now if you click multiple times rapidly the animation takes place immediately and it looks like the bear is hoping instead of walking.

The solution to it looks simple that I should check if animation is already running and if running the new animation should not take place.

The following is a part of my code.

CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("AnimBear.plist");
CCSpriteBatchNode* spriteBatchNode = CCSpriteBatchNode::create("AnimBear.png", 8);

this->addChild(spriteBatchNode,10);
        CCArray *tempArray = new CCArray();
char buffer[15];
for (int i = 1; i <= 8 ; i++) 
    {
sprintf(buffer,"bear%i.png", i);
tempArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(buffer));      
}

CCAnimation *bearWalkingAnimation = CCAnimation::create(tempArray,0.1f);
startAnimation = CCSprite::createWithSpriteFrameName("bear1.png");
startAnimation->setPosition(ccp (350 , CCDirector::sharedDirector()->getWinSize().height/2 -100));
startAnimation->setScale(0.5f);

startAnimation->setTag(5);

//Animation for bear walking    

bearAnimate = CCAnimate::create(bearWalkingAnimation);

Here bearAnimate is a global variable and i wish to know if its currently playing the animation.

How do I do it.?
Thank you.

  • 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-11T20:55:04+00:00Added an answer on June 11, 2026 at 8:55 pm

    Assume the Sprite that runs the action is

    CCSprite* bear;
    

    I think you can use something like

    bear->numberOfRunningActions()
    

    numberOfRunningActions( ) returns an unsigned integer, so to check if there are no actions, you would have to check if it returns 0

    if ( bear -> numberOfRunningActions( ) == 0 ) {
       CCLOG( "No actions running." );
    } else {
       CCLOG( "Actions running." );
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im currently learning python (in the very begining), so I still have some doubts
I am currently learning C, and am having some issues with trying to make
I'm currently learning GEF (as in the Eclipse project), and while doing so have
Im currently learning multiple inheritance and ran into a problem creating a function that
We have a fairly rich e-learning app, built mostly using cocos2d. Currently we are
I am new to Cocos2D and currently still learning. I have bene attempting to
I´m currently learning WPF and the use of MultiTrigger and Conditions to set some
I'm currently learning JPCT for Android. After reading some tutorials and examples, I've noticed
I'm currently learning assembler and writing some program in real mode. I have some
I am currently learning C++ for a programming course. I noticed that my professor's

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.