理論部分
緩動動作的基類,繼承自 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();
