Finishing MoveTo Action run next function

I have 3 seconds MoveTo Action,
CCMoveTo::actionWithDuration(3 , ccp(indexHair~~>getPosition.x , indexHair~~>getPosition().y-300 ));

when the 3 seconds action finished, the program will run next function.

hvae any function can use in cocos2d-x?

thank you very much

>when the 3 seconds action finished, the program will run next function.

I am sorry, I don’t know what’s your meaning?

Sorry.
I’m meaning the animation have 3 second.
after during 3 second. he can call other function to do something.

You can use CCSequence like:

runAction(CCSequence::actions(
        CCMoveTo::actionWithDuration(3 , ccp(indexHair->getPosition().x , indexHair->getPosition().y-300 )),
    CCCallFunc::actionWithTarget(this,callfunc_selector(yourClass::yourFunction)),
            NULL));

It run the first action,and run second after first done. Of course, you can use more action. Remember to add Null as the last action

Thank you very much!

I have another question similar to the question at the start of this topic. I have some label. I wanna run some action on this label. Let it be updating the user score. What do I need to do with that label after action has finished? What the optimal sequence of doings will be here?

I think something like this:

  1. Creating CCLabelTTF
  2. this~~>addChild;
  3. this~~>runAction( …. );
  4. this->removeChild( thatLabel )

Is it right? So for the every update of the user score we need to create CCLabelTTF, add it to our scene, run action and remove it? And we should repeat it every update of the user score? I think it too many actions just for visual effect. Or it all about beauty requires sacrifice? :slight_smile:

I don’t know any other ways to restart our action for successfully next start…

before you removeChild you should judge the action is done or no
like this:
CCAction *action = ….
runAction(action);
if (action->isDone)
removeChild(thatLabel);

庐陵某 萧 wrote:

before you removeChild you should judge the action is done or no
like this:
CCAction *action = ….
runAction(action);
if (action->isDone)
removeChild(thatLabel);

Oh, ok! But is there a way to reset our user score label to its original view without removing it and recreating again?

Airex Rest wrote:

庐陵某 萧 wrote:
> before you removeChild you should judge the action is done or no
> like this:
> CCAction *action = ….
> runAction(action);
> if (action->isDone)
> removeChild(thatLabel);
>
Oh, ok! But is there a way to reset our user score label to its original view without removing it and recreating again?

maybe, but I don’t know…