‎Cocos2d-x 学习笔记(11.8) DelayTime ReverseTime TargetedAction ActionFloat Blink TintTo TintBy ResizeTo ResizeBy

1. DelayTime

通过create方法create(float d)设置时长,update方法没有任何操作。可以用于动作之间的延迟。

2. ReverseTime

create方法create(FiniteTimeAction *action)设置绑定的action。upadte方法中执行_other->update(1 - time),进度为正常倒放的进度,实现倒放的效果。

3. TargetedAction

通过create(Node* target, FiniteTimeAction* action)方法将action与node绑定。在runAction时,实际上是对绑定的node执行绑定的action。

4. ActionFloat

从from到to按进度取的值作为value,传给回调函数。

create(float duration, float from, float to, ActionFloatCallback callback)把参数赋给变量。

startWithTarget中,_delta是to-from。

update方法:

float value = _to - _delta * (1 - t); // from + t * delta

    if (_callback)
    {
        // report back value to caller
        _callback(value);
    }

5. TintTo TintBy

create方法传入rgb三个值,To和By是在startWithTarget和update有相对和绝对的区别。

6. ResizeTo ResizeBy

create传入Size,To和By是在startWithTarget和update有相对和绝对的区别。

7. Blink

闪烁。create(float duration, int blinks)设置间隔和闪烁次数。

startWithTarget,获取可见性:

_originalState = target->isVisible();

update:

if (_target && ! isDone())
    {
        float slice = 1.0f / _times; // 一次闪烁的占比
        float m = fmodf(time, slice);  //本次闪烁完成进度
        _target->setVisible(m > slice / 2 ? true : false); //本次进度到了一半就可见,没到一半就隐藏,实现了闪烁效果
    }
posted @ 2019-07-30 09:57  deepcho  阅读(588)  评论(0编辑  收藏  举报

博客园提供博客支持
爱我所选,选我所爱。
❤️