2
\$\begingroup\$

With Cocos2D I can run two actions in parallel by simply using runAction and I can use a CCSequence two run several actions after each other. However what I could not find is:

  • Run two actions simultaneously
  • When both actions are done, trigger a third CCAction

It must be really easy but I seem to use the wrong search keywords on Google. :-)

The only possible solution I have found so far is to use a delayed action as the first element of a CCSequence and then start the third action. But it "feels" wrong.

\$\endgroup\$
3
\$\begingroup\$

Use this code (cocos2dx v3.x):

node->runAction( Sequence::create( Spawn::create(A, B, nullptr),
                                    C,
                                    nullptr));

This is what happen:

  1. A and B start simultaneously
  2. After the longer one finished, C start.

Important: Remember that you should use finite action when using Sequence. for example you should not use RepeatForever for actions when use them in Sequence.


cocos2d v2.x

node->runAction( CCSequence::create( CCSpawn::create(A, B, NULL),
                                    C,
                                    NULL));
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.