Cocos2d-x study notes (13) ActionEase

ActionEase ActionInterval is a subclass can be executed shifting operation. The internal operation of the packaging, by pass into the update time, together with different calculation formula to calculate a new time, as an internal operation of the time, and thus the internal operation of the transmission.

Buffering action defined for each class using macro definitions in three ways:

EASE_TEMPLATE_IMPL(CLASSNAME, TWEEN_FUNC, REVERSE_CLASSNAME)

Three parameters: the class name, function update calls, reverse execution of the class name.

The method defined: create, update, clone, reserve (create methods performing inverse class parameter).

It defines: index buffer, Sine cushion, jumping cushion, back cushion shock ......

EASERATE_TEMPLATE_IMPL(CLASSNAME, TWEEN_FUNC)

Two parameters: the class name, update function calls

It defines: EaseIn / Out / InOut. The method includes a parameter create float rate, assigned to _rate.

EASEELASTIC_TEMPLATE_IMPL(CLASSNAME, TWEEN_FUNC, REVERSE_CLASSNAME)

It defines: EaseElasticIn / Out / InOut. The method includes a parameter create float period, assigned to _period.

TWEEN_FUNC function calculates a new time through the buffer of time, as a parameter of the internal time update of action.

The horizontal axis is the time function of the image of the packaging, increasing uniformly with time, the vertical axis is passed to the internal operation of the update time. The slope can be seen as the rate of operation of the internal operation, the slope is less than 1, slower than normal speed, is greater than 1, faster than the normal speed.

1. index buffer EaseExponential

EaseExponentialIn first slow after the fast, tweenfunc corresponding method:

EaseExponentialOut slow down after, tweenfunc:

EaseExponentialInOut buffer progress to 0.5 for the sector, in two cases, showing the effect is to slow after the fast then slow.

    if(time == 0 || time == 1) 
        return time;
    
    if (time < 0.5f)
        return 0.5f * powf(2, 10 * (time * 2 - 1));

    return 0.5f * (-powf(2, -10 * (time * 2 - 1)) + 2);

2. EaseSine

Out:

In:

InOut:

3. EaseBounce

4. EaseBack

5. EaseQuadraticAction 2 quadratic function

Out:

In:

 InOut

 6. EaseQuarticAction 4 times Function

In/Out:

 

InOut:

7. EaseQuinticActionIn 5 times Function

In/Out:

 InOut:

8. EaseCircleAction circular function

In/Out:

InOut:

9. EaseCubicAction 3 times Function

In/Out:

InOut:

10. Ease

create need to pass parameters rate, as the number of computing power when tweenfunc.

对于In:rate>1时,rate越大, 慢速时间越长越慢,加速越晚越快。0<rate<1时,rate越小,加速越早越快,慢速时间越长越慢。

对于Out:rate>1时,rate越大,加速越早越快,慢速时间越长越慢。0<rate<1时,rate越小,慢速时间越长越慢,加速越晚越快。0

对于InOut:rate>1时越大,越靠近0.5时间进度时加速,加速越快时间越短。1/2

11. EaseElastic

create参数period越接近0,弹性效果越明显。为0消失。

Guess you like

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