2013-06-06 12:02:54 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "CCTweenFunction.h"
|
|
|
|
#include "CCUtilMath.h"
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
NS_CC_EXT_ARMATURE_BEGIN
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::tweenTo(float from, float change, float time, float duration, CCTweenType tweenType)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
float delta = 0;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
|
|
|
switch (tweenType)
|
|
|
|
{
|
|
|
|
case Linear:
|
|
|
|
delta = linear(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Sine_EaseIn:
|
|
|
|
delta = sineEaseIn(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Sine_EaseOut:
|
|
|
|
delta = sineEaseOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Sine_EaseInOut:
|
|
|
|
delta = sineEaseInOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Quad_EaseIn:
|
|
|
|
delta = quadEaseIn(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Quad_EaseOut:
|
|
|
|
delta = quadEaseOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Quad_EaseInOut:
|
|
|
|
delta = quadEaseInOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Cubic_EaseIn:
|
|
|
|
delta = cubicEaseIn(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Cubic_EaseOut:
|
|
|
|
delta = cubicEaseOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Cubic_EaseInOut:
|
|
|
|
delta = cubicEaseInOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Quart_EaseIn:
|
|
|
|
delta = quartEaseIn(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Quart_EaseOut:
|
|
|
|
delta = quartEaseOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Quart_EaseInOut:
|
|
|
|
delta = quartEaseInOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Quint_EaseIn:
|
|
|
|
delta = quintEaseIn(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Quint_EaseOut:
|
|
|
|
delta = quintEaseOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Quint_EaseInOut:
|
|
|
|
delta = quintEaseInOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Expo_EaseIn:
|
|
|
|
delta = expoEaseIn(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Expo_EaseOut:
|
|
|
|
delta = expoEaseOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Expo_EaseInOut:
|
|
|
|
delta = expoEaseInOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Circ_EaseIn:
|
|
|
|
delta = circEaseIn(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Circ_EaseOut:
|
|
|
|
delta = circEaseOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Circ_EaseInOut:
|
|
|
|
delta = circEaseInOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Elastic_EaseIn:
|
|
|
|
delta = elasticEaseIn(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Elastic_EaseOut:
|
|
|
|
delta = elasticEaseOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Elastic_EaseInOut:
|
|
|
|
delta = elasticEaseInOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case Back_EaseIn:
|
|
|
|
delta = backEaseIn(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Back_EaseOut:
|
|
|
|
delta = backEaseOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Back_EaseInOut:
|
|
|
|
delta = backEaseInOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Bounce_EaseIn:
|
|
|
|
delta = bounceEaseIn(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Bounce_EaseOut:
|
|
|
|
delta = bounceEaseOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
case Bounce_EaseInOut:
|
|
|
|
delta = bounceEaseInOut(time, 0, 1, duration);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
delta = sineEaseInOut(time, 0, 1, duration);
|
|
|
|
break;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
return delta;
|
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::linear(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
return c * t / d + b;
|
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::quadEaseIn(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
return c * t * t + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::quadEaseOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
return -c * t * (t - 2) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::quadEaseInOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
if ((t / 2) < 1)
|
2013-06-06 12:02:54 +08:00
|
|
|
return c / 2 * t * t + b;
|
2013-09-13 18:07:37 +08:00
|
|
|
--t;
|
2013-06-07 21:00:45 +08:00
|
|
|
return -c / 2 * (t * (t - 2) - 1) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::cubicEaseIn(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
return c * t * t * t + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::cubicEaseOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t = t / d - 1;
|
2013-06-07 20:54:35 +08:00
|
|
|
return c * (t * t * t + 1) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::cubicEaseInOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
if ((t / 2) < 1)
|
2013-06-06 12:02:54 +08:00
|
|
|
return c / 2 * t * t * t + b;
|
2013-06-07 20:54:35 +08:00
|
|
|
t -= 2;
|
2013-09-13 18:07:37 +08:00
|
|
|
return c / 2 * (t * t * t + 2) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::quartEaseIn(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
return c * t * t * t * t + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::quartEaseOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t = t / d - 1;
|
2013-06-07 20:54:35 +08:00
|
|
|
return -c * (t * t * t * t - 1) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::quartEaseInOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
if ((t / 2) < 1)
|
2013-06-06 12:02:54 +08:00
|
|
|
return c / 2 * t * t * t * t + b;
|
2013-06-07 20:54:35 +08:00
|
|
|
t -= 2;
|
2013-09-13 18:07:37 +08:00
|
|
|
return -c / 2 * (t * t * t * t - 2) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::quintEaseIn(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
return c * t * t * t * t * t + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::quintEaseOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t = t / d - 1;
|
2013-06-07 20:54:35 +08:00
|
|
|
return c * (t * t * t * t * t + 1) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::quintEaseInOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
if ((t / 2) < 1)
|
2013-06-06 12:02:54 +08:00
|
|
|
return c / 2 * t * t * t * t * t + b;
|
2013-09-13 18:07:37 +08:00
|
|
|
t -= 2;
|
2013-06-07 20:54:35 +08:00
|
|
|
return c / 2 * (t * t * t * t * t + 2) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::sineEaseIn(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
return -c * cos(t / d * (M_PI / 2)) + c + b;
|
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::sineEaseOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
return c * sin(t / d * (M_PI / 2)) + b;
|
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::sineEaseInOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
return -c / 2 * (cos(M_PI * t / d) - 1) + b;
|
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::expoEaseIn(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
return (t == 0) ? b : c * pow(2, 10 * (t / d - 1)) + b;
|
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::expoEaseOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
return (t == d) ? b + c : c * (-pow(2, -10 * t / d) + 1) + b;
|
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::expoEaseInOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
if (t == 0)
|
|
|
|
return b;
|
|
|
|
if (t == d)
|
|
|
|
return b + c;
|
|
|
|
if ((t /= d / 2) < 1)
|
|
|
|
return c / 2 * pow(2, 10 * (t - 1)) + b;
|
2013-09-13 18:07:37 +08:00
|
|
|
--t;
|
2013-06-07 20:54:35 +08:00
|
|
|
return c / 2 * (-pow(2, -10 * t) + 2) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::circEaseIn(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
return -c * (sqrt(1 - t * t) - 1) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::circEaseOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t = t / d - 1;
|
2013-06-07 20:54:35 +08:00
|
|
|
return c * sqrt(1 - t * t) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::circEaseInOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
if ((t / 2) < 1)
|
2013-06-06 12:02:54 +08:00
|
|
|
return -c / 2 * (sqrt(1 - t * t) - 1) + b;
|
2013-09-13 18:07:37 +08:00
|
|
|
t -= 2;
|
2013-06-07 20:54:35 +08:00
|
|
|
return c / 2 * (sqrt(1 - t * t) + 1) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::elasticEaseIn(float t, float b, float c, float d, float a, float p)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
float s = 0;
|
|
|
|
if (t == 0)
|
|
|
|
return b;
|
2013-06-07 20:54:35 +08:00
|
|
|
t /= d;
|
2013-09-13 18:07:37 +08:00
|
|
|
if (t == 1)
|
2013-06-06 12:02:54 +08:00
|
|
|
return b + c;
|
|
|
|
if (!p)
|
|
|
|
p = d * .3;
|
2013-06-07 10:52:32 +08:00
|
|
|
if (!a || a < abs(c))
|
|
|
|
{
|
2013-06-06 12:02:54 +08:00
|
|
|
a = c;
|
|
|
|
s = p / 4;
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
else
|
2013-06-06 12:02:54 +08:00
|
|
|
s = p / (2 * M_PI) * asin(c / a);
|
2013-09-13 18:07:37 +08:00
|
|
|
t -= 1;
|
2013-06-07 20:54:35 +08:00
|
|
|
return -(a * pow(2, 10 * t) * sin((t * d - s) * (2 * M_PI) / p)) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::elasticEaseOut(float t, float b, float c, float d, float a, float p)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
float s = 0;
|
|
|
|
if (t == 0)
|
|
|
|
return b;
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
if (t == 1)
|
2013-06-06 12:02:54 +08:00
|
|
|
return b + c;
|
|
|
|
if (!p)
|
|
|
|
p = d * .3;
|
2013-06-07 10:52:32 +08:00
|
|
|
if (!a || a < abs(c))
|
|
|
|
{
|
2013-06-06 12:02:54 +08:00
|
|
|
a = c;
|
|
|
|
s = p / 4;
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
else
|
2013-06-06 12:02:54 +08:00
|
|
|
s = p / (2 * M_PI) * asin(c / a);
|
|
|
|
return (a * pow(2, -10 * t) * sin((t * d - s) * (2 * M_PI) / p) + c + b);
|
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::elasticEaseInOut(float t, float b, float c, float d, float a, float p)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
float s = 0;
|
|
|
|
if (t == 0)
|
|
|
|
return b;
|
2013-06-07 20:54:35 +08:00
|
|
|
t /= d;
|
2013-09-13 18:07:37 +08:00
|
|
|
if ((t / 2) == 2)
|
2013-06-06 12:02:54 +08:00
|
|
|
return b + c;
|
|
|
|
if (!p)
|
|
|
|
p = d * (.3 * 1.5);
|
2013-06-07 10:52:32 +08:00
|
|
|
if (!a || a < abs(c))
|
|
|
|
{
|
2013-06-06 12:02:54 +08:00
|
|
|
a = c;
|
|
|
|
s = p / 4;
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
else
|
2013-06-06 12:02:54 +08:00
|
|
|
s = p / (2 * M_PI) * asin(c / a);
|
|
|
|
if (t < 1)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
|
|
|
t -= 1;
|
|
|
|
return -.5 * (a * pow(2, 10 * t) * sin((t * d - s) * (2 * M_PI) / p)) + b;
|
|
|
|
}
|
|
|
|
t -= 1;
|
2013-06-07 20:54:35 +08:00
|
|
|
return a * pow(2, -10 * t) * sin((t * d - s) * (2 * M_PI) / p) * .5 + c + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::backEaseIn(float t, float b, float c, float d, float s)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
if (s == 0)
|
|
|
|
s = 1.70158f;
|
2013-06-07 20:54:35 +08:00
|
|
|
t /= d;
|
2013-09-13 18:07:37 +08:00
|
|
|
return c * t * t * ((s + 1) * t - s) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::backEaseOut(float t, float b, float c, float d, float s)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
if (s == 0)
|
|
|
|
s = 1.70158f;
|
2013-09-13 18:07:37 +08:00
|
|
|
t = t / d - 1;
|
2013-06-07 20:54:35 +08:00
|
|
|
return c * (t * t * ((s + 1) * t + s) + 1) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::backEaseInOut(float t, float b, float c, float d, float s)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
if (s == 0)
|
|
|
|
s = 1.70158f;
|
|
|
|
if ((t /= d / 2) < 1)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
|
|
|
s *= (1.525f);
|
|
|
|
return c / 2 * (t * t * ((s + 1) * t - s)) + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
t -= 2;
|
|
|
|
s *= (1.525f);
|
2013-06-07 20:54:35 +08:00
|
|
|
return c / 2 * (t * t * ((s + 1) * t + s) + 2) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::bounceEaseIn(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
return c - bounceEaseOut(d - t, 0, c, d) + b;
|
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::bounceEaseOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t /= d;
|
2013-06-07 20:54:35 +08:00
|
|
|
if (t < (1 / 2.75f))
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-06-06 12:02:54 +08:00
|
|
|
return c * (7.5625f * t * t) + b;
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
else if (t < (2 / 2.75f))
|
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t -= (1.5f / 2.75f);
|
2013-06-07 20:54:35 +08:00
|
|
|
return c * (7.5625f * t * t + .75f) + b;
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
else if (t < (2.5f / 2.75f))
|
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t -= (2.25f / 2.75f);
|
2013-06-07 20:54:35 +08:00
|
|
|
return c * (7.5625f * t * t + .9375f) + b;
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
t -= (2.625f / 2.75f);
|
2013-06-07 20:54:35 +08:00
|
|
|
return c * (7.5625f * t * t + .984375f) + b;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
float TweenFunction::bounceEaseInOut(float t, float b, float c, float d)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
if (t < d / 2)
|
|
|
|
return bounceEaseIn(t * 2, 0, c, d) * .5 + b;
|
|
|
|
else
|
|
|
|
return bounceEaseOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
NS_CC_EXT_ARMATURE_END
|