cocos代码研究(10)ActionEase子类学习笔记

理论部分

缓动动作的基类,继承自 ActionInterval类。ActionEase本身是一个抽象的概念父类,开发者最好不要在代码中直接创建它的对象,因为它没有具体的执行效果,这一类的子类速度变化大致可以划分成三种。

  • 由快变慢;
  • 由慢变快;
  • 又慢变快再由快变慢;

被 EaseBackIn, EaseBackInOut, EaseBackOut, EaseBezierAction, EaseBounce, EaseCircleActionIn, EaseCircleActionInOut, EaseCircleActionOut, EaseCubicActionIn, EaseCubicActionInOut, EaseCubicActionOut, EaseElastic, EaseExponentialIn,EaseExponentialInOut, EaseExponentialOut, EaseQuadraticActionIn, EaseQuadraticActionInOut, EaseQuadraticActionOut, EaseQuarticActionIn, EaseQuarticActionInOut, EaseQuarticActionOut, EaseQuinticActionIn, EaseQuinticActionInOut,EaseQuinticActionOut, EaseRateAction, EaseSineIn, EaseSineInOut , 以及 EaseSineOut 继承.

代码部分

EaseRateAction类及其子类被 EaseIn, EaseInOut , EaseOut的API 

设定速率。
void setRate (float rate)

获取速率
float getRate () const

用内部动作和速率参数来创建一个动作。
static EaseRateAction * create (ActionInterval *action, //一个给定的内部动作
float rate) //一个给定的速率

用内部动作和速率参数来创建一个由慢到快的动作
static EaseIn * create (ActionInterval *action, //内部动作。
float rate) //速率。

用内部动作和速率参数来创建一个由快到慢的动作。
static EaseOut * create (ActionInterval *action, //内部动作。
float rate) //速率。

用内部动作和速率参数来创建一个从慢到快再从快到慢的动作。
static EaseInOut * create (ActionInterval *action, //内部动作。
float rate) //速率。

实例:

    auto move = MoveBy::create(3, Vec2(VisibleRect::right().x-130,0));
    auto move_back = move->reverse();
    
    auto move_ease_in = EaseIn::create(move->clone(), 2.5f);
    auto move_ease_in_back = move_ease_in->reverse();
    
    auto move_ease_out = EaseOut::create(move->clone(), 2.5f);
    auto move_ease_out_back = move_ease_out->reverse();
原文地址:https://www.cnblogs.com/damowang/p/4858750.html