cocos2d-x2.0 problem plz help me out!

here is my problem
when i was use cocos2d-x 1.0.x:
1.I create a CCSprite
2.I let the sprite run a CCRepeatForever animation like walking.
3.When the sprite hitted by a monster i let the sprite run a injure animation just call runaction but do not stop the previous walking action.
4.The result is sprite stop walking and play injure animation and keep walking when the injure animation finished.(that’s what i am expected)

When i use cocos2d-x 2.0
I also create a sprite and let it run repeat forever walking animation and when sprite hitted by monster i let sprite run injure action once but the walking action is not stoped so the walking animation and injure animation are play simultaneously.
What’s wrong with it? How to fix this problem?

Could you paste some codes?

You need to stop the action like described here http://www.cocos2d-x.org/boards/6/topics/21783

tks Cristian
the problem is not i do not know how to stop the previous action

but when i create a repeat forever action first and i do not stop

it then i let the sprite run a second action which is a finite

action just once. i ll show you some code example like below:

CCSprite * spr = CCSprite::create(“spr.png”);
spr~~>setposition);
this~~>addChild(spr,2,2);
CCAnimation ani = MyCreateAnim;
CCAnimate
walk = CCAnimate::create(ani);
spr~~>runAction);
//so when i do that code the spr will keep walking forever and
then i create a button and write some code in that button’s
callback like:
CCSprite *spr = this~~>getChildByTag(2);
if(spr)
{
CCAnimation anim = MyCreateAnim;
CCAnimate
anim_attack = CCAnimate::create(anim);
spr->runAction(anim_attack);
}

//the code is done
when i was use cocos2d-x 1.0 version the result is the walking

animate was stoped and play the attack animate once then keep

playing the walking animate! but when i use cocos2d-x 2.0 version

the result become the walking animate is not stop and both of the

animate are playing simultaneously! i have no idea that why this

happened.

Hi,
As far as I see you want to play the walk animation and on button click to play once the attack animation and then continue with the walk animation. In this case why don’t you just stop the walk animation on button press, then run a sequence with two actions, the first being the attack animation and the second being a callback to a method that starts the walk animation again. Something like this:

void Game::startWalk()
{
    CCSprite spr = (CCSprite)this->getChildByTag(2);
    if(spr) {
        CCAnimation *ani = MyCreateAnim(SPR_PLAYER, ACTION_WALK);
        CCAnimate *walk = CCAnimate::create(ani);
        spr->runAction(CCRepeatForever::create(walk));
    }
}

in the callback:

CCSprite spr = (CCSprite)this->getChildByTag(2);
if(spr) {
     CCAnimation *anim = MyCreateAnim(SPR_PLAYER, ACTION_ATTACK);
     CCAnimate *anim_attack = CCAnimate::create(anim);
     spr->runAction(CCSequence::createWithTwoActions(anim_attack,CCCallFunc::create(spr,callfunc_selector(Game::startWalk))));
}

Of course you should optimize things by creating the animations only once.

Hope this helps