Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck If animation is running in cocos2d-x
    primarykey
    data
    text
    <p>I am currently learning cocos2D-x and am doing some sprite animation.<br> 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.</p> <p>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.</p> <p>The following is a part of my code.</p> <pre><code>CCSpriteFrameCache::sharedSpriteFrameCache()-&gt;addSpriteFramesWithFile("AnimBear.plist"); CCSpriteBatchNode* spriteBatchNode = CCSpriteBatchNode::create("AnimBear.png", 8); this-&gt;addChild(spriteBatchNode,10); CCArray *tempArray = new CCArray(); char buffer[15]; for (int i = 1; i &lt;= 8 ; i++) { sprintf(buffer,"bear%i.png", i); tempArray-&gt;addObject(CCSpriteFrameCache::sharedSpriteFrameCache()-&gt;spriteFrameByName(buffer)); } CCAnimation *bearWalkingAnimation = CCAnimation::create(tempArray,0.1f); startAnimation = CCSprite::createWithSpriteFrameName("bear1.png"); startAnimation-&gt;setPosition(ccp (350 , CCDirector::sharedDirector()-&gt;getWinSize().height/2 -100)); startAnimation-&gt;setScale(0.5f); startAnimation-&gt;setTag(5); //Animation for bear walking bearAnimate = CCAnimate::create(bearWalkingAnimation); </code></pre> <p>Here bearAnimate is a global variable and i wish to know if its currently playing the animation.</p> <p>How do I do it.?<br>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload