Cocos2d-x study notes (11.10) Spawn

Spawn have multiple action simultaneously.

There are many different Spawn create methods, eventually called createWithTwoActions (FiniteTimeAction * action1, FiniteTimeAction * action2) method.

createWithTwoActions call initWithTwoActions method:

Two action variable initialization:

_one = action1;
_two = action2;

If two action at different times, to create a Sequence, contains a short action and suspend action, with Sequence replace short-term action, to achieve the same time two action:

        if (d1 > d2)
        {
            _two = Sequence::createWithTwoActions(action2, DelayTime::create(d1 - d2));
        } 
        else if (d1 < d2)
        {
            _one = Sequence::createWithTwoActions(action1, DelayTime::create(d2 - d1));
        }

startWithTarget two action initialization:

    ActionInterval::startWithTarget(target);
    _one->startWithTarget(target);
    _two->startWithTarget(target);

two action update of the update execution.

Guess you like

Origin www.cnblogs.com/deepcho/p/cocos2dx-spawn.html