示例#1
0
        public override void update(float t)
        {
            int   found = 0;
            float new_t = 0;

            CCAction action0 = _actions [0];
            CCAction action1 = _actions [1];

            if (FloatUtils.Small(t, _split))
            {
                // action[0]
                found = 0;
                if (!FloatUtils.EQ(_split, 0))
                {
                    new_t = t / _split;
                }
                else
                {
                    new_t = 1;
                }
            }
            else
            {
                // action[1]
                found = 1;
                if (FloatUtils.EQ(_split, 1))
                {
                    new_t = 1;
                }
                else
                {
                    new_t = (t - _split) / (1 - _split);
                }
            }

            if (found == 1)
            {
                if (_last == -1)
                {
                    // action[0] was skipped, execute it.
                    action0.startWithTarget(_target);
                    action0.update(1.0f);
                    action0.stop();
                }
                else if (_last == 0)
                {
                    // switching to action 1. stop action 0.
                    action0.update(1.0f);
                    action0.stop();
                }
            }
            else if (found == 0 && _last == 1)
            {
                // Reverse mode ?
                // XXX: Bug. this case doesn't contemplate when _last==-1, found=0 and in "reverse mode"
                // since it will require a hack to know if an action is on reverse mode or not.
                // "step" should be overriden, and the "reverseMode" value propagated to inner Sequences.
                action1.update(0);
                action1.stop();
            }

            // Last action found and it is done.
            if (found == _last && _actions[found].isDone())
            {
                return;
            }

            // New action. Start it.
            if (found != _last)
            {
                _actions[found].startWithTarget(_target);
            }

            _actions[found].update(new_t);
            _last = found;
        }