mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5371 from andyque/refactorActionEase
closed #3620: Merge cocostudio/CCActionXxx to CCAction。
This commit is contained in:
commit
ee4972ae96
|
@ -1 +1 @@
|
|||
a7af0ccd05e86210026f7c72d6f5a7be8e17fe3d
|
||||
8f6bd203bc07c8cff824450938e8931abc027341
|
|
@ -12,6 +12,7 @@ CCAction.cpp \
|
|||
CCActionCamera.cpp \
|
||||
CCActionCatmullRom.cpp \
|
||||
CCActionEase.cpp \
|
||||
CCTweenFunction.cpp \
|
||||
CCActionGrid.cpp \
|
||||
CCActionGrid3D.cpp \
|
||||
CCActionInstant.cpp \
|
||||
|
|
|
@ -32,6 +32,7 @@ THE SOFTWARE.
|
|||
*/
|
||||
|
||||
#include "CCActionEase.h"
|
||||
#include "CCTweenFunction.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -137,7 +138,7 @@ EaseIn* EaseIn::clone() const
|
|||
|
||||
void EaseIn::update(float time)
|
||||
{
|
||||
_inner->update(powf(time, _rate));
|
||||
_inner->update(tweenfunc::easeIn(time, _rate));
|
||||
}
|
||||
|
||||
EaseIn* EaseIn::reverse() const
|
||||
|
@ -177,7 +178,7 @@ EaseOut* EaseOut::clone() const
|
|||
|
||||
void EaseOut::update(float time)
|
||||
{
|
||||
_inner->update(powf(time, 1 / _rate));
|
||||
_inner->update(tweenfunc::easeOut(time, _rate));
|
||||
}
|
||||
|
||||
EaseOut* EaseOut::reverse() const
|
||||
|
@ -217,15 +218,7 @@ EaseInOut* EaseInOut::clone() const
|
|||
|
||||
void EaseInOut::update(float time)
|
||||
{
|
||||
time *= 2;
|
||||
if (time < 1)
|
||||
{
|
||||
_inner->update(0.5f * powf(time, _rate));
|
||||
}
|
||||
else
|
||||
{
|
||||
_inner->update(1.0f - 0.5f * powf(2-time, _rate));
|
||||
}
|
||||
_inner->update(tweenfunc::easeInOut(time, _rate));
|
||||
}
|
||||
|
||||
// InOut and OutIn are symmetrical
|
||||
|
@ -266,7 +259,7 @@ EaseExponentialIn* EaseExponentialIn::clone() const
|
|||
|
||||
void EaseExponentialIn::update(float time)
|
||||
{
|
||||
_inner->update(time == 0 ? 0 : powf(2, 10 * (time/1 - 1)) - 1 * 0.001f);
|
||||
_inner->update(tweenfunc::expoEaseIn(time));
|
||||
}
|
||||
|
||||
ActionEase * EaseExponentialIn::reverse() const
|
||||
|
@ -306,7 +299,7 @@ EaseExponentialOut* EaseExponentialOut::clone() const
|
|||
|
||||
void EaseExponentialOut::update(float time)
|
||||
{
|
||||
_inner->update(time == 1 ? 1 : (-powf(2, -10 * time / 1) + 1));
|
||||
_inner->update(tweenfunc::expoEaseOut(time));
|
||||
}
|
||||
|
||||
ActionEase* EaseExponentialOut::reverse() const
|
||||
|
@ -347,17 +340,7 @@ EaseExponentialInOut* EaseExponentialInOut::clone() const
|
|||
|
||||
void EaseExponentialInOut::update(float time)
|
||||
{
|
||||
time /= 0.5f;
|
||||
if (time < 1)
|
||||
{
|
||||
time = 0.5f * powf(2, 10 * (time - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
time = 0.5f * (-powf(2, -10 * (time - 1)) + 2);
|
||||
}
|
||||
|
||||
_inner->update(time);
|
||||
_inner->update(tweenfunc::expoEaseInOut(time));
|
||||
}
|
||||
|
||||
EaseExponentialInOut* EaseExponentialInOut::reverse() const
|
||||
|
@ -398,7 +381,7 @@ EaseSineIn* EaseSineIn::clone() const
|
|||
|
||||
void EaseSineIn::update(float time)
|
||||
{
|
||||
_inner->update(-1 * cosf(time * (float)M_PI_2) + 1);
|
||||
_inner->update(tweenfunc::sineEaseIn(time));
|
||||
}
|
||||
|
||||
ActionEase* EaseSineIn::reverse() const
|
||||
|
@ -439,7 +422,7 @@ EaseSineOut* EaseSineOut::clone() const
|
|||
|
||||
void EaseSineOut::update(float time)
|
||||
{
|
||||
_inner->update(sinf(time * (float)M_PI_2));
|
||||
_inner->update(tweenfunc::sineEaseOut(time));
|
||||
}
|
||||
|
||||
ActionEase* EaseSineOut::reverse(void) const
|
||||
|
@ -480,7 +463,7 @@ EaseSineInOut* EaseSineInOut::clone() const
|
|||
|
||||
void EaseSineInOut::update(float time)
|
||||
{
|
||||
_inner->update(-0.5f * (cosf((float)M_PI * time) - 1));
|
||||
_inner->update(tweenfunc::sineEaseInOut(time));
|
||||
}
|
||||
|
||||
EaseSineInOut* EaseSineInOut::reverse() const
|
||||
|
@ -541,19 +524,7 @@ EaseElasticIn* EaseElasticIn::clone() const
|
|||
|
||||
void EaseElasticIn::update(float time)
|
||||
{
|
||||
float newT = 0;
|
||||
if (time == 0 || time == 1)
|
||||
{
|
||||
newT = time;
|
||||
}
|
||||
else
|
||||
{
|
||||
float s = _period / 4;
|
||||
time = time - 1;
|
||||
newT = -powf(2, 10 * time) * sinf((time - s) * M_PI_X_2 / _period);
|
||||
}
|
||||
|
||||
_inner->update(newT);
|
||||
_inner->update(tweenfunc::elasticEaseIn(time, NULL));
|
||||
}
|
||||
|
||||
EaseElastic* EaseElasticIn::reverse() const
|
||||
|
@ -599,18 +570,7 @@ EaseElasticOut* EaseElasticOut::clone() const
|
|||
|
||||
void EaseElasticOut::update(float time)
|
||||
{
|
||||
float newT = 0;
|
||||
if (time == 0 || time == 1)
|
||||
{
|
||||
newT = time;
|
||||
}
|
||||
else
|
||||
{
|
||||
float s = _period / 4;
|
||||
newT = powf(2, -10 * time) * sinf((time - s) * M_PI_X_2 / _period) + 1;
|
||||
}
|
||||
|
||||
_inner->update(newT);
|
||||
_inner->update(tweenfunc::elasticEaseOut(time, NULL));
|
||||
}
|
||||
|
||||
EaseElastic* EaseElasticOut::reverse() const
|
||||
|
@ -656,33 +616,7 @@ EaseElasticInOut* EaseElasticInOut::clone() const
|
|||
|
||||
void EaseElasticInOut::update(float time)
|
||||
{
|
||||
float newT = 0;
|
||||
if (time == 0 || time == 1)
|
||||
{
|
||||
newT = time;
|
||||
}
|
||||
else
|
||||
{
|
||||
time = time * 2;
|
||||
if ( _period == 0)
|
||||
{
|
||||
_period = 0.3f * 1.5f;
|
||||
}
|
||||
|
||||
float s = _period / 4;
|
||||
|
||||
time = time - 1;
|
||||
if (time < 0)
|
||||
{
|
||||
newT = -0.5f * powf(2, 10 * time) * sinf((time -s) * M_PI_X_2 / _period);
|
||||
}
|
||||
else
|
||||
{
|
||||
newT = powf(2, -10 * time) * sinf((time - s) * M_PI_X_2 / _period) * 0.5f + 1;
|
||||
}
|
||||
}
|
||||
|
||||
_inner->update(newT);
|
||||
_inner->update(tweenfunc::elasticEaseInOut(time, NULL));
|
||||
}
|
||||
|
||||
EaseElasticInOut* EaseElasticInOut::reverse() const
|
||||
|
@ -694,27 +628,6 @@ EaseElasticInOut* EaseElasticInOut::reverse() const
|
|||
// EaseBounce
|
||||
//
|
||||
|
||||
float EaseBounce::bounceTime(float time)
|
||||
{
|
||||
if (time < 1 / 2.75)
|
||||
{
|
||||
return 7.5625f * time * time;
|
||||
} else
|
||||
if (time < 2 / 2.75)
|
||||
{
|
||||
time -= 1.5f / 2.75f;
|
||||
return 7.5625f * time * time + 0.75f;
|
||||
} else
|
||||
if(time < 2.5 / 2.75)
|
||||
{
|
||||
time -= 2.25f / 2.75f;
|
||||
return 7.5625f * time * time + 0.9375f;
|
||||
}
|
||||
|
||||
time -= 2.625f / 2.75f;
|
||||
return 7.5625f * time * time + 0.984375f;
|
||||
}
|
||||
|
||||
//
|
||||
// EaseBounceIn
|
||||
//
|
||||
|
@ -748,8 +661,7 @@ EaseBounceIn* EaseBounceIn::clone() const
|
|||
|
||||
void EaseBounceIn::update(float time)
|
||||
{
|
||||
float newT = 1 - bounceTime(1 - time);
|
||||
_inner->update(newT);
|
||||
_inner->update(tweenfunc::bounceEaseIn(time));
|
||||
}
|
||||
|
||||
EaseBounce* EaseBounceIn::reverse() const
|
||||
|
@ -790,8 +702,7 @@ EaseBounceOut* EaseBounceOut::clone() const
|
|||
|
||||
void EaseBounceOut::update(float time)
|
||||
{
|
||||
float newT = bounceTime(time);
|
||||
_inner->update(newT);
|
||||
_inner->update(tweenfunc::bounceEaseOut(time));
|
||||
}
|
||||
|
||||
EaseBounce* EaseBounceOut::reverse() const
|
||||
|
@ -832,18 +743,7 @@ EaseBounceInOut* EaseBounceInOut::clone() const
|
|||
|
||||
void EaseBounceInOut::update(float time)
|
||||
{
|
||||
float newT = 0;
|
||||
if (time < 0.5f)
|
||||
{
|
||||
time = time * 2;
|
||||
newT = (1 - bounceTime(1 - time)) * 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
newT = bounceTime(time * 2 - 1) * 0.5f + 0.5f;
|
||||
}
|
||||
|
||||
_inner->update(newT);
|
||||
_inner->update(tweenfunc::bounceEaseInOut(time));
|
||||
}
|
||||
|
||||
EaseBounceInOut* EaseBounceInOut::reverse() const
|
||||
|
@ -884,8 +784,7 @@ EaseBackIn* EaseBackIn::clone() const
|
|||
|
||||
void EaseBackIn::update(float time)
|
||||
{
|
||||
float overshoot = 1.70158f;
|
||||
_inner->update(time * time * ((overshoot + 1) * time - overshoot));
|
||||
_inner->update(tweenfunc::backEaseIn(time));
|
||||
}
|
||||
|
||||
ActionEase* EaseBackIn::reverse() const
|
||||
|
@ -926,10 +825,7 @@ EaseBackOut* EaseBackOut::clone() const
|
|||
|
||||
void EaseBackOut::update(float time)
|
||||
{
|
||||
float overshoot = 1.70158f;
|
||||
|
||||
time = time - 1;
|
||||
_inner->update(time * time * ((overshoot + 1) * time + overshoot) + 1);
|
||||
_inner->update(tweenfunc::backEaseOut(time));
|
||||
}
|
||||
|
||||
ActionEase* EaseBackOut::reverse() const
|
||||
|
@ -970,18 +866,7 @@ EaseBackInOut* EaseBackInOut::clone() const
|
|||
|
||||
void EaseBackInOut::update(float time)
|
||||
{
|
||||
float overshoot = 1.70158f * 1.525f;
|
||||
|
||||
time = time * 2;
|
||||
if (time < 1)
|
||||
{
|
||||
_inner->update((time * time * ((overshoot + 1) * time - overshoot)) / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
time = time - 2;
|
||||
_inner->update((time * time * ((overshoot + 1) * time + overshoot)) / 2 + 1);
|
||||
}
|
||||
_inner->update(tweenfunc::backEaseInOut(time));
|
||||
}
|
||||
|
||||
EaseBackInOut* EaseBackInOut::reverse() const
|
||||
|
@ -989,4 +874,670 @@ EaseBackInOut* EaseBackInOut::reverse() const
|
|||
return EaseBackInOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EaseBezierAction* EaseBezierAction::create(cocos2d::ActionInterval* action)
|
||||
{
|
||||
EaseBezierAction *ret = new EaseBezierAction();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EaseBezierAction::setBezierParamer( float p0, float p1, float p2, float p3)
|
||||
{
|
||||
_p0 = p0;
|
||||
_p1 = p1;
|
||||
_p2 = p2;
|
||||
_p3 = p3;
|
||||
}
|
||||
|
||||
EaseBezierAction* EaseBezierAction::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseBezierAction();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->setBezierParamer(_p0,_p1,_p2,_p3);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseBezierAction::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::bezieratFunction(_p0,_p1,_p2,_p3,time));
|
||||
}
|
||||
|
||||
EaseBezierAction* EaseBezierAction::reverse() const
|
||||
{
|
||||
EaseBezierAction* reverseAction = EaseBezierAction::create(_inner->reverse());
|
||||
reverseAction->setBezierParamer(_p3,_p2,_p1,_p0);
|
||||
return reverseAction;
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuadraticActionIn
|
||||
//
|
||||
|
||||
EaseQuadraticActionIn* EaseQuadraticActionIn::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuadraticActionIn *ret = new EaseQuadraticActionIn();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuadraticActionIn* EaseQuadraticActionIn::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuadraticActionIn();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuadraticActionIn::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::quadraticIn(time));
|
||||
}
|
||||
|
||||
EaseQuadraticActionIn* EaseQuadraticActionIn::reverse() const
|
||||
{
|
||||
return EaseQuadraticActionIn::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuadraticActionOut
|
||||
//
|
||||
|
||||
EaseQuadraticActionOut* EaseQuadraticActionOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuadraticActionOut *ret = new EaseQuadraticActionOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuadraticActionOut* EaseQuadraticActionOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuadraticActionOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuadraticActionOut::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::quadraticOut(time));
|
||||
}
|
||||
|
||||
EaseQuadraticActionOut* EaseQuadraticActionOut::reverse() const
|
||||
{
|
||||
return EaseQuadraticActionOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuadraticActionInOut
|
||||
//
|
||||
|
||||
EaseQuadraticActionInOut* EaseQuadraticActionInOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuadraticActionInOut *ret = new EaseQuadraticActionInOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuadraticActionInOut* EaseQuadraticActionInOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuadraticActionInOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuadraticActionInOut::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::quadraticInOut(time));
|
||||
}
|
||||
|
||||
EaseQuadraticActionInOut* EaseQuadraticActionInOut::reverse() const
|
||||
{
|
||||
return EaseQuadraticActionInOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuarticActionIn
|
||||
//
|
||||
|
||||
EaseQuarticActionIn* EaseQuarticActionIn::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuarticActionIn *ret = new EaseQuarticActionIn();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuarticActionIn* EaseQuarticActionIn::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuarticActionIn();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuarticActionIn::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::quartEaseIn(time));
|
||||
}
|
||||
|
||||
EaseQuarticActionIn* EaseQuarticActionIn::reverse() const
|
||||
{
|
||||
return EaseQuarticActionIn::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuarticActionOut
|
||||
//
|
||||
|
||||
EaseQuarticActionOut* EaseQuarticActionOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuarticActionOut *ret = new EaseQuarticActionOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuarticActionOut* EaseQuarticActionOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuarticActionOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuarticActionOut::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::quartEaseOut(time));
|
||||
}
|
||||
|
||||
EaseQuarticActionOut* EaseQuarticActionOut::reverse() const
|
||||
{
|
||||
return EaseQuarticActionOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuarticActionInOut
|
||||
//
|
||||
|
||||
EaseQuarticActionInOut* EaseQuarticActionInOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuarticActionInOut *ret = new EaseQuarticActionInOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuarticActionInOut* EaseQuarticActionInOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuarticActionInOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuarticActionInOut::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::quartEaseInOut(time));
|
||||
}
|
||||
|
||||
EaseQuarticActionInOut* EaseQuarticActionInOut::reverse() const
|
||||
{
|
||||
return EaseQuarticActionInOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuinticActionIn
|
||||
//
|
||||
|
||||
EaseQuinticActionIn* EaseQuinticActionIn::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuinticActionIn *ret = new EaseQuinticActionIn();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuinticActionIn* EaseQuinticActionIn::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuinticActionIn();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuinticActionIn::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::quintEaseIn(time));
|
||||
}
|
||||
|
||||
EaseQuinticActionIn* EaseQuinticActionIn::reverse() const
|
||||
{
|
||||
return EaseQuinticActionIn::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuinticActionOut
|
||||
//
|
||||
|
||||
EaseQuinticActionOut* EaseQuinticActionOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuinticActionOut *ret = new EaseQuinticActionOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuinticActionOut* EaseQuinticActionOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuinticActionOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuinticActionOut::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::quintEaseOut(time));
|
||||
}
|
||||
|
||||
EaseQuinticActionOut* EaseQuinticActionOut::reverse() const
|
||||
{
|
||||
return EaseQuinticActionOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuinticActionInOut
|
||||
//
|
||||
|
||||
EaseQuinticActionInOut* EaseQuinticActionInOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuinticActionInOut *ret = new EaseQuinticActionInOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuinticActionInOut* EaseQuinticActionInOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuinticActionInOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuinticActionInOut::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::quintEaseInOut(time));
|
||||
}
|
||||
|
||||
EaseQuinticActionInOut* EaseQuinticActionInOut::reverse() const
|
||||
{
|
||||
return EaseQuinticActionInOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCircleActionIn
|
||||
//
|
||||
|
||||
EaseCircleActionIn* EaseCircleActionIn::create(ActionInterval* action)
|
||||
{
|
||||
EaseCircleActionIn *ret = new EaseCircleActionIn();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCircleActionIn* EaseCircleActionIn::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCircleActionIn();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCircleActionIn::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::circEaseIn(time));
|
||||
}
|
||||
|
||||
EaseCircleActionIn* EaseCircleActionIn::reverse() const
|
||||
{
|
||||
return EaseCircleActionIn::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCircleActionOut
|
||||
//
|
||||
|
||||
EaseCircleActionOut* EaseCircleActionOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseCircleActionOut *ret = new EaseCircleActionOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCircleActionOut* EaseCircleActionOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCircleActionOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCircleActionOut::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::circEaseOut(time));
|
||||
}
|
||||
|
||||
EaseCircleActionOut* EaseCircleActionOut::reverse() const
|
||||
{
|
||||
return EaseCircleActionOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCircleActionInOut
|
||||
//
|
||||
|
||||
EaseCircleActionInOut* EaseCircleActionInOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseCircleActionInOut *ret = new EaseCircleActionInOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCircleActionInOut* EaseCircleActionInOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCircleActionInOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCircleActionInOut::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::circEaseInOut(time));
|
||||
}
|
||||
|
||||
EaseCircleActionInOut* EaseCircleActionInOut::reverse() const
|
||||
{
|
||||
return EaseCircleActionInOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCubicActionIn
|
||||
//
|
||||
|
||||
EaseCubicActionIn* EaseCubicActionIn::create(ActionInterval* action)
|
||||
{
|
||||
EaseCubicActionIn *ret = new EaseCubicActionIn();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCubicActionIn* EaseCubicActionIn::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCubicActionIn();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCubicActionIn::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::cubicEaseIn(time));
|
||||
}
|
||||
|
||||
EaseCubicActionIn* EaseCubicActionIn::reverse() const
|
||||
{
|
||||
return EaseCubicActionIn::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCubicActionOut
|
||||
//
|
||||
|
||||
EaseCubicActionOut* EaseCubicActionOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseCubicActionOut *ret = new EaseCubicActionOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCubicActionOut* EaseCubicActionOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCubicActionOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCubicActionOut::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::cubicEaseOut(time));
|
||||
}
|
||||
|
||||
EaseCubicActionOut* EaseCubicActionOut::reverse() const
|
||||
{
|
||||
return EaseCubicActionOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCubicActionInOut
|
||||
//
|
||||
|
||||
EaseCubicActionInOut* EaseCubicActionInOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseCubicActionInOut *ret = new EaseCubicActionInOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCubicActionInOut* EaseCubicActionInOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCubicActionInOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCubicActionInOut::update(float time)
|
||||
{
|
||||
_inner->update(tweenfunc::cubicEaseInOut(time));
|
||||
}
|
||||
|
||||
EaseCubicActionInOut* EaseCubicActionInOut::reverse() const
|
||||
{
|
||||
return EaseCubicActionInOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -65,7 +65,6 @@ protected:
|
|||
|
||||
/** The inner action */
|
||||
ActionInterval *_inner;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(ActionEase);
|
||||
};
|
||||
|
@ -426,7 +425,6 @@ private:
|
|||
class CC_DLL EaseBounce : public ActionEase
|
||||
{
|
||||
public:
|
||||
float bounceTime(float time);
|
||||
|
||||
// Overrides
|
||||
virtual EaseBounce* clone() const override = 0;
|
||||
|
@ -590,6 +588,369 @@ private:
|
|||
CC_DISALLOW_COPY_AND_ASSIGN(EaseBackInOut);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@brief Ease Bezier
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseBezierAction : public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseBezierAction* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseBezierAction* clone() const override;
|
||||
virtual EaseBezierAction* reverse() const override;
|
||||
|
||||
virtual void setBezierParamer( float p0, float p1, float p2, float p3);
|
||||
|
||||
protected:
|
||||
EaseBezierAction() {}
|
||||
virtual ~EaseBezierAction() {}
|
||||
|
||||
float _p0;
|
||||
float _p1;
|
||||
float _p2;
|
||||
float _p3;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseBezierAction);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quadratic In
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuadraticActionIn:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuadraticActionIn* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuadraticActionIn* clone() const override;
|
||||
virtual EaseQuadraticActionIn* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuadraticActionIn() {}
|
||||
virtual ~EaseQuadraticActionIn() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuadraticActionIn);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quadratic Out
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuadraticActionOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuadraticActionOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuadraticActionOut* clone() const override;
|
||||
virtual EaseQuadraticActionOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuadraticActionOut() {}
|
||||
virtual ~EaseQuadraticActionOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuadraticActionOut);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quadratic InOut
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuadraticActionInOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuadraticActionInOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuadraticActionInOut* clone() const override;
|
||||
virtual EaseQuadraticActionInOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuadraticActionInOut() {}
|
||||
virtual ~EaseQuadraticActionInOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuadraticActionInOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quartic In
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuarticActionIn:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuarticActionIn* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuarticActionIn* clone() const override;
|
||||
virtual EaseQuarticActionIn* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuarticActionIn() {}
|
||||
virtual ~EaseQuarticActionIn() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuarticActionIn);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quartic Out
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuarticActionOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuarticActionOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuarticActionOut* clone() const override;
|
||||
virtual EaseQuarticActionOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuarticActionOut() {}
|
||||
virtual ~EaseQuarticActionOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuarticActionOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quartic InOut
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuarticActionInOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuarticActionInOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuarticActionInOut* clone() const override;
|
||||
virtual EaseQuarticActionInOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuarticActionInOut() {}
|
||||
virtual ~EaseQuarticActionInOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuarticActionInOut);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@brief Ease Quintic In
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuinticActionIn:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuinticActionIn* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuinticActionIn* clone() const override;
|
||||
virtual EaseQuinticActionIn* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuinticActionIn() {}
|
||||
virtual ~EaseQuinticActionIn() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuinticActionIn);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quintic Out
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuinticActionOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuinticActionOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuinticActionOut* clone() const override;
|
||||
virtual EaseQuinticActionOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuinticActionOut() {}
|
||||
virtual ~EaseQuinticActionOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuinticActionOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quintic InOut
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuinticActionInOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuinticActionInOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuinticActionInOut* clone() const override;
|
||||
virtual EaseQuinticActionInOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuinticActionInOut() {}
|
||||
virtual ~EaseQuinticActionInOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuinticActionInOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Circle In
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCircleActionIn:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCircleActionIn* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCircleActionIn* clone() const override;
|
||||
virtual EaseCircleActionIn* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCircleActionIn() {}
|
||||
virtual ~EaseCircleActionIn() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCircleActionIn);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Circle Out
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCircleActionOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCircleActionOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCircleActionOut* clone() const override;
|
||||
virtual EaseCircleActionOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCircleActionOut() {}
|
||||
virtual ~EaseCircleActionOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCircleActionOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Circle InOut
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCircleActionInOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCircleActionInOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCircleActionInOut* clone() const override;
|
||||
virtual EaseCircleActionInOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCircleActionInOut() {}
|
||||
virtual ~EaseCircleActionInOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCircleActionInOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Cubic In
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCubicActionIn:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCubicActionIn* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCubicActionIn* clone() const override;
|
||||
virtual EaseCubicActionIn* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCubicActionIn() {}
|
||||
virtual ~EaseCubicActionIn() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCubicActionIn);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Cubic Out
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCubicActionOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCubicActionOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCubicActionOut* clone() const override;
|
||||
virtual EaseCubicActionOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCubicActionOut() {}
|
||||
virtual ~EaseCubicActionOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCubicActionOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Cubic InOut
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCubicActionInOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCubicActionInOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCubicActionInOut* clone() const override;
|
||||
virtual EaseCubicActionInOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCubicActionInOut() {}
|
||||
virtual ~EaseCubicActionInOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCubicActionInOut);
|
||||
};
|
||||
|
||||
// end of actions group
|
||||
/// @}
|
||||
|
||||
|
|
|
@ -22,170 +22,179 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "cocostudio/CCTweenFunction.h"
|
||||
#include "cocostudio/CCUtilMath.h"
|
||||
#include "CCTweenFunction.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
namespace tweenfunc {
|
||||
|
||||
|
||||
#ifndef M_PI_X_2
|
||||
#define M_PI_X_2 (float)M_PI * 2.0f
|
||||
#endif
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
float TweenFunction::tweenTo(float time, TweenType type, float *easingParam)
|
||||
|
||||
|
||||
float tweenTo(float time, TweenType type, float *easingParam)
|
||||
{
|
||||
float delta = 0;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CUSTOM_EASING:
|
||||
delta = customEase(time, easingParam);
|
||||
break;
|
||||
|
||||
case Linear:
|
||||
delta = linear(time);
|
||||
break;
|
||||
|
||||
case Sine_EaseIn:
|
||||
delta = sineEaseIn(time);
|
||||
break;
|
||||
case Sine_EaseOut:
|
||||
delta = sineEaseOut(time);
|
||||
break;
|
||||
case Sine_EaseInOut:
|
||||
delta = sineEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Quad_EaseIn:
|
||||
delta = quadEaseIn(time);
|
||||
break;
|
||||
case Quad_EaseOut:
|
||||
delta = quadEaseOut(time);
|
||||
break;
|
||||
case Quad_EaseInOut:
|
||||
delta = quadEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Cubic_EaseIn:
|
||||
delta = cubicEaseIn(time);
|
||||
break;
|
||||
case Cubic_EaseOut:
|
||||
delta = cubicEaseOut(time);
|
||||
break;
|
||||
case Cubic_EaseInOut:
|
||||
delta = cubicEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Quart_EaseIn:
|
||||
delta = quartEaseIn(time);
|
||||
break;
|
||||
case Quart_EaseOut:
|
||||
delta = quartEaseOut(time);
|
||||
break;
|
||||
case Quart_EaseInOut:
|
||||
delta = quartEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Quint_EaseIn:
|
||||
delta = quintEaseIn(time);
|
||||
break;
|
||||
case Quint_EaseOut:
|
||||
delta = quintEaseOut(time);
|
||||
break;
|
||||
case Quint_EaseInOut:
|
||||
delta = quintEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Expo_EaseIn:
|
||||
delta = expoEaseIn(time);
|
||||
break;
|
||||
case Expo_EaseOut:
|
||||
delta = expoEaseOut(time);
|
||||
break;
|
||||
case Expo_EaseInOut:
|
||||
delta = expoEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Circ_EaseIn:
|
||||
delta = circEaseIn(time);
|
||||
break;
|
||||
case Circ_EaseOut:
|
||||
delta = circEaseOut(time);
|
||||
break;
|
||||
case Circ_EaseInOut:
|
||||
delta = circEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Elastic_EaseIn:
|
||||
delta = elasticEaseIn(time, easingParam);
|
||||
break;
|
||||
case Elastic_EaseOut:
|
||||
delta = elasticEaseOut(time, easingParam);
|
||||
break;
|
||||
case Elastic_EaseInOut:
|
||||
delta = elasticEaseInOut(time, easingParam);
|
||||
break;
|
||||
|
||||
|
||||
case Back_EaseIn:
|
||||
delta = backEaseIn(time);
|
||||
break;
|
||||
case Back_EaseOut:
|
||||
delta = backEaseOut(time);
|
||||
break;
|
||||
case Back_EaseInOut:
|
||||
delta = backEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Bounce_EaseIn:
|
||||
delta = bounceEaseIn(time);
|
||||
break;
|
||||
case Bounce_EaseOut:
|
||||
delta = bounceEaseOut(time);
|
||||
break;
|
||||
case Bounce_EaseInOut:
|
||||
delta = bounceEaseInOut(time);
|
||||
break;
|
||||
|
||||
default:
|
||||
delta = sineEaseInOut(time);
|
||||
break;
|
||||
case CUSTOM_EASING:
|
||||
delta = customEase(time, easingParam);
|
||||
break;
|
||||
|
||||
case Linear:
|
||||
delta = linear(time);
|
||||
break;
|
||||
|
||||
case Sine_EaseIn:
|
||||
delta = sineEaseIn(time);
|
||||
break;
|
||||
case Sine_EaseOut:
|
||||
delta = sineEaseOut(time);
|
||||
break;
|
||||
case Sine_EaseInOut:
|
||||
delta = sineEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Quad_EaseIn:
|
||||
delta = quadEaseIn(time);
|
||||
break;
|
||||
case Quad_EaseOut:
|
||||
delta = quadEaseOut(time);
|
||||
break;
|
||||
case Quad_EaseInOut:
|
||||
delta = quadEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Cubic_EaseIn:
|
||||
delta = cubicEaseIn(time);
|
||||
break;
|
||||
case Cubic_EaseOut:
|
||||
delta = cubicEaseOut(time);
|
||||
break;
|
||||
case Cubic_EaseInOut:
|
||||
delta = cubicEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Quart_EaseIn:
|
||||
delta = quartEaseIn(time);
|
||||
break;
|
||||
case Quart_EaseOut:
|
||||
delta = quartEaseOut(time);
|
||||
break;
|
||||
case Quart_EaseInOut:
|
||||
delta = quartEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Quint_EaseIn:
|
||||
delta = quintEaseIn(time);
|
||||
break;
|
||||
case Quint_EaseOut:
|
||||
delta = quintEaseOut(time);
|
||||
break;
|
||||
case Quint_EaseInOut:
|
||||
delta = quintEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Expo_EaseIn:
|
||||
delta = expoEaseIn(time);
|
||||
break;
|
||||
case Expo_EaseOut:
|
||||
delta = expoEaseOut(time);
|
||||
break;
|
||||
case Expo_EaseInOut:
|
||||
delta = expoEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Circ_EaseIn:
|
||||
delta = circEaseIn(time);
|
||||
break;
|
||||
case Circ_EaseOut:
|
||||
delta = circEaseOut(time);
|
||||
break;
|
||||
case Circ_EaseInOut:
|
||||
delta = circEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Elastic_EaseIn:
|
||||
delta = elasticEaseIn(time, easingParam);
|
||||
break;
|
||||
case Elastic_EaseOut:
|
||||
delta = elasticEaseOut(time, easingParam);
|
||||
break;
|
||||
case Elastic_EaseInOut:
|
||||
delta = elasticEaseInOut(time, easingParam);
|
||||
break;
|
||||
|
||||
|
||||
case Back_EaseIn:
|
||||
delta = backEaseIn(time);
|
||||
break;
|
||||
case Back_EaseOut:
|
||||
delta = backEaseOut(time);
|
||||
break;
|
||||
case Back_EaseInOut:
|
||||
delta = backEaseInOut(time);
|
||||
break;
|
||||
|
||||
case Bounce_EaseIn:
|
||||
delta = bounceEaseIn(time);
|
||||
break;
|
||||
case Bounce_EaseOut:
|
||||
delta = bounceEaseOut(time);
|
||||
break;
|
||||
case Bounce_EaseInOut:
|
||||
delta = bounceEaseInOut(time);
|
||||
break;
|
||||
|
||||
default:
|
||||
delta = sineEaseInOut(time);
|
||||
break;
|
||||
}
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
// Linear
|
||||
float TweenFunction::linear(float time)
|
||||
float linear(float time)
|
||||
{
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
// Sine Ease
|
||||
float TweenFunction::sineEaseIn(float time)
|
||||
float sineEaseIn(float time)
|
||||
{
|
||||
return -1 * cosf(time * (float)M_PI_2) + 1;
|
||||
}
|
||||
float TweenFunction::sineEaseOut(float time)
|
||||
|
||||
float sineEaseOut(float time)
|
||||
{
|
||||
return sinf(time * (float)M_PI_2);
|
||||
}
|
||||
float TweenFunction::sineEaseInOut(float time)
|
||||
|
||||
float sineEaseInOut(float time)
|
||||
{
|
||||
return -0.5f * (cosf((float)M_PI * time) - 1);
|
||||
}
|
||||
|
||||
|
||||
// Quad Ease
|
||||
float TweenFunction::quadEaseIn(float time)
|
||||
float quadEaseIn(float time)
|
||||
{
|
||||
return time * time;
|
||||
}
|
||||
float TweenFunction::quadEaseOut(float time)
|
||||
|
||||
float quadEaseOut(float time)
|
||||
{
|
||||
return -1 * time * (time - 2);
|
||||
}
|
||||
float TweenFunction::quadEaseInOut(float time)
|
||||
|
||||
float quadEaseInOut(float time)
|
||||
{
|
||||
time = time*2;
|
||||
if (time < 1)
|
||||
|
@ -197,16 +206,16 @@ float TweenFunction::quadEaseInOut(float time)
|
|||
|
||||
|
||||
// Cubic Ease
|
||||
float TweenFunction::cubicEaseIn(float time)
|
||||
float cubicEaseIn(float time)
|
||||
{
|
||||
return time * time * time;
|
||||
}
|
||||
float TweenFunction::cubicEaseOut(float time)
|
||||
float cubicEaseOut(float time)
|
||||
{
|
||||
time -= 1;
|
||||
return (time * time * time + 1);
|
||||
}
|
||||
float TweenFunction::cubicEaseInOut(float time)
|
||||
float cubicEaseInOut(float time)
|
||||
{
|
||||
time = time*2;
|
||||
if (time < 1)
|
||||
|
@ -217,16 +226,18 @@ float TweenFunction::cubicEaseInOut(float time)
|
|||
|
||||
|
||||
// Quart Ease
|
||||
float TweenFunction::quartEaseIn(float time)
|
||||
float quartEaseIn(float time)
|
||||
{
|
||||
return time * time * time * time;
|
||||
}
|
||||
float TweenFunction::quartEaseOut(float time)
|
||||
|
||||
float quartEaseOut(float time)
|
||||
{
|
||||
time -= 1;
|
||||
return -(time * time * time * time - 1);
|
||||
}
|
||||
float TweenFunction::quartEaseInOut(float time)
|
||||
|
||||
float quartEaseInOut(float time)
|
||||
{
|
||||
time = time*2;
|
||||
if (time < 1)
|
||||
|
@ -237,16 +248,18 @@ float TweenFunction::quartEaseInOut(float time)
|
|||
|
||||
|
||||
// Quint Ease
|
||||
float TweenFunction::quintEaseIn(float time)
|
||||
float quintEaseIn(float time)
|
||||
{
|
||||
return time * time * time * time * time;
|
||||
}
|
||||
float TweenFunction::quintEaseOut(float time)
|
||||
|
||||
float quintEaseOut(float time)
|
||||
{
|
||||
time -=1;
|
||||
return (time * time * time * time * time + 1);
|
||||
}
|
||||
float TweenFunction::quintEaseInOut(float time)
|
||||
|
||||
float quintEaseInOut(float time)
|
||||
{
|
||||
time = time*2;
|
||||
if (time < 1)
|
||||
|
@ -257,15 +270,15 @@ float TweenFunction::quintEaseInOut(float time)
|
|||
|
||||
|
||||
// Expo Ease
|
||||
float TweenFunction::expoEaseIn(float time)
|
||||
float expoEaseIn(float time)
|
||||
{
|
||||
return time == 0 ? 0 : powf(2, 10 * (time/1 - 1)) - 1 * 0.001f;
|
||||
}
|
||||
float TweenFunction::expoEaseOut(float time)
|
||||
float expoEaseOut(float time)
|
||||
{
|
||||
return time == 1 ? 1 : (-powf(2, -10 * time / 1) + 1);
|
||||
}
|
||||
float TweenFunction::expoEaseInOut(float time)
|
||||
float expoEaseInOut(float time)
|
||||
{
|
||||
time /= 0.5f;
|
||||
if (time < 1)
|
||||
|
@ -282,16 +295,16 @@ float TweenFunction::expoEaseInOut(float time)
|
|||
|
||||
|
||||
// Circ Ease
|
||||
float TweenFunction::circEaseIn(float time)
|
||||
float circEaseIn(float time)
|
||||
{
|
||||
return -1 * (sqrt(1 - time * time) - 1);
|
||||
}
|
||||
float TweenFunction::circEaseOut(float time)
|
||||
float circEaseOut(float time)
|
||||
{
|
||||
time = time - 1;
|
||||
return sqrt(1 - time * time);
|
||||
}
|
||||
float TweenFunction::circEaseInOut(float time)
|
||||
float circEaseInOut(float time)
|
||||
{
|
||||
time = time * 2;
|
||||
if (time < 1)
|
||||
|
@ -302,7 +315,7 @@ float TweenFunction::circEaseInOut(float time)
|
|||
|
||||
|
||||
// Elastic Ease
|
||||
float TweenFunction::elasticEaseIn(float time, float *easingParam)
|
||||
float elasticEaseIn(float time, float *easingParam)
|
||||
{
|
||||
float period = 0.3f;
|
||||
|
||||
|
@ -325,7 +338,7 @@ float TweenFunction::elasticEaseIn(float time, float *easingParam)
|
|||
|
||||
return newT;
|
||||
}
|
||||
float TweenFunction::elasticEaseOut(float time, float *easingParam)
|
||||
float elasticEaseOut(float time, float *easingParam)
|
||||
{
|
||||
float period = 0.3f;
|
||||
|
||||
|
@ -347,7 +360,7 @@ float TweenFunction::elasticEaseOut(float time, float *easingParam)
|
|||
|
||||
return newT;
|
||||
}
|
||||
float TweenFunction::elasticEaseInOut(float time, float *easingParam)
|
||||
float elasticEaseInOut(float time, float *easingParam)
|
||||
{
|
||||
float period = 0.3f;
|
||||
|
||||
|
@ -386,19 +399,19 @@ float TweenFunction::elasticEaseInOut(float time, float *easingParam)
|
|||
|
||||
|
||||
// Back Ease
|
||||
float TweenFunction::backEaseIn(float time)
|
||||
float backEaseIn(float time)
|
||||
{
|
||||
float overshoot = 1.70158f;
|
||||
return time * time * ((overshoot + 1) * time - overshoot);
|
||||
}
|
||||
float TweenFunction::backEaseOut(float time)
|
||||
float backEaseOut(float time)
|
||||
{
|
||||
float overshoot = 1.70158f;
|
||||
|
||||
time = time - 1;
|
||||
return time * time * ((overshoot + 1) * time + overshoot) + 1;
|
||||
}
|
||||
float TweenFunction::backEaseInOut(float time)
|
||||
float backEaseInOut(float time)
|
||||
{
|
||||
float overshoot = 1.70158f * 1.525f;
|
||||
|
||||
|
@ -422,32 +435,32 @@ float bounceTime(float time)
|
|||
if (time < 1 / 2.75)
|
||||
{
|
||||
return 7.5625f * time * time;
|
||||
} else
|
||||
if (time < 2 / 2.75)
|
||||
{
|
||||
time -= 1.5f / 2.75f;
|
||||
return 7.5625f * time * time + 0.75f;
|
||||
} else
|
||||
if(time < 2.5 / 2.75)
|
||||
{
|
||||
time -= 2.25f / 2.75f;
|
||||
return 7.5625f * time * time + 0.9375f;
|
||||
}
|
||||
}
|
||||
else if (time < 2 / 2.75)
|
||||
{
|
||||
time -= 1.5f / 2.75f;
|
||||
return 7.5625f * time * time + 0.75f;
|
||||
}
|
||||
else if(time < 2.5 / 2.75)
|
||||
{
|
||||
time -= 2.25f / 2.75f;
|
||||
return 7.5625f * time * time + 0.9375f;
|
||||
}
|
||||
|
||||
time -= 2.625f / 2.75f;
|
||||
return 7.5625f * time * time + 0.984375f;
|
||||
time -= 2.625f / 2.75f;
|
||||
return 7.5625f * time * time + 0.984375f;
|
||||
}
|
||||
float TweenFunction::bounceEaseIn(float time)
|
||||
float bounceEaseIn(float time)
|
||||
{
|
||||
return 1 - bounceTime(1 - time);
|
||||
}
|
||||
|
||||
float TweenFunction::bounceEaseOut(float time)
|
||||
float bounceEaseOut(float time)
|
||||
{
|
||||
return bounceTime(time);
|
||||
}
|
||||
|
||||
float TweenFunction::bounceEaseInOut(float time)
|
||||
float bounceEaseInOut(float time)
|
||||
{
|
||||
float newT = 0;
|
||||
if (time < 0.5f)
|
||||
|
@ -465,7 +478,7 @@ float TweenFunction::bounceEaseInOut(float time)
|
|||
|
||||
|
||||
// Custom Ease
|
||||
float TweenFunction::customEase(float time, float *easingParam)
|
||||
float customEase(float time, float *easingParam)
|
||||
{
|
||||
if (easingParam)
|
||||
{
|
||||
|
@ -475,5 +488,61 @@ float TweenFunction::customEase(float time, float *easingParam)
|
|||
return time;
|
||||
}
|
||||
|
||||
|
||||
float easeIn(float time, float rate)
|
||||
{
|
||||
return powf(time, rate);
|
||||
}
|
||||
|
||||
float easeOut(float time, float rate)
|
||||
{
|
||||
return powf(time, 1 / rate);
|
||||
}
|
||||
|
||||
float easeInOut(float time, float rate)
|
||||
{
|
||||
time *= 2;
|
||||
if (time < 1)
|
||||
{
|
||||
return 0.5f * powf(time, rate);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (1.0f - 0.5f * powf(2 - time, rate));
|
||||
}
|
||||
}
|
||||
|
||||
float quadraticIn(float time)
|
||||
{
|
||||
return powf(time,2);
|
||||
}
|
||||
|
||||
float quadraticOut(float time)
|
||||
{
|
||||
return -time*(time-2);
|
||||
}
|
||||
|
||||
float quadraticInOut(float time)
|
||||
{
|
||||
|
||||
float resultTime = time;
|
||||
time = time*2;
|
||||
if (time < 1)
|
||||
{
|
||||
resultTime = time * time * 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
--time;
|
||||
resultTime = -0.5f * (time * (time - 2) - 1);
|
||||
}
|
||||
return resultTime;
|
||||
}
|
||||
|
||||
float bezieratFunction( float a, float b, float c, float d, float t )
|
||||
{
|
||||
return (powf(1-t,3) * a + 3*t*(powf(1-t,2))*b + 3*powf(t,2)*(1-t)*c + powf(t,3)*d );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,148 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCTWEENFUNCTION_H__
|
||||
#define __CCTWEENFUNCTION_H__
|
||||
|
||||
#include "CCPlatformMacros.h"
|
||||
#include "ccMacros.h"
|
||||
#include <math.h>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
namespace tweenfunc {
|
||||
enum TweenType
|
||||
{
|
||||
CUSTOM_EASING = -1,
|
||||
|
||||
Linear,
|
||||
|
||||
Sine_EaseIn,
|
||||
Sine_EaseOut,
|
||||
Sine_EaseInOut,
|
||||
|
||||
|
||||
Quad_EaseIn,
|
||||
Quad_EaseOut,
|
||||
Quad_EaseInOut,
|
||||
|
||||
Cubic_EaseIn,
|
||||
Cubic_EaseOut,
|
||||
Cubic_EaseInOut,
|
||||
|
||||
Quart_EaseIn,
|
||||
Quart_EaseOut,
|
||||
Quart_EaseInOut,
|
||||
|
||||
Quint_EaseIn,
|
||||
Quint_EaseOut,
|
||||
Quint_EaseInOut,
|
||||
|
||||
Expo_EaseIn,
|
||||
Expo_EaseOut,
|
||||
Expo_EaseInOut,
|
||||
|
||||
Circ_EaseIn,
|
||||
Circ_EaseOut,
|
||||
Circ_EaseInOut,
|
||||
|
||||
Elastic_EaseIn,
|
||||
Elastic_EaseOut,
|
||||
Elastic_EaseInOut,
|
||||
|
||||
Back_EaseIn,
|
||||
Back_EaseOut,
|
||||
Back_EaseInOut,
|
||||
|
||||
Bounce_EaseIn,
|
||||
Bounce_EaseOut,
|
||||
Bounce_EaseInOut,
|
||||
|
||||
TWEEN_EASING_MAX = 10000
|
||||
};
|
||||
|
||||
|
||||
//tween functions for CCActionEase
|
||||
float easeIn(float time, float rate);
|
||||
float easeOut(float time, float rate);
|
||||
float easeInOut(float time, float rate);
|
||||
|
||||
float bezieratFunction( float a, float b, float c, float d, float t );
|
||||
|
||||
float quadraticIn(float time);
|
||||
float quadraticOut(float time);
|
||||
float quadraticInOut(float time);
|
||||
|
||||
|
||||
float tweenTo(float time, TweenType type, float *easingParam);
|
||||
|
||||
float linear(float time);
|
||||
|
||||
|
||||
float sineEaseIn(float time);
|
||||
float sineEaseOut(float time);
|
||||
float sineEaseInOut(float time);
|
||||
|
||||
float quadEaseIn(float time);
|
||||
float quadEaseOut(float time);
|
||||
float quadEaseInOut(float time);
|
||||
|
||||
float cubicEaseIn(float time);
|
||||
float cubicEaseOut(float time);
|
||||
float cubicEaseInOut(float time);
|
||||
|
||||
float quartEaseIn(float time);
|
||||
float quartEaseOut(float time);
|
||||
float quartEaseInOut(float time);
|
||||
|
||||
float quintEaseIn(float time);
|
||||
float quintEaseOut(float time);
|
||||
float quintEaseInOut(float time);
|
||||
|
||||
float expoEaseIn(float time);
|
||||
float expoEaseOut(float time);
|
||||
float expoEaseInOut(float time);
|
||||
|
||||
float circEaseIn(float time);
|
||||
float circEaseOut(float time);
|
||||
float circEaseInOut(float time);
|
||||
|
||||
float elasticEaseIn(float time, float *easingParam);
|
||||
float elasticEaseOut(float time, float *easingParam);
|
||||
float elasticEaseInOut(float time, float *easingParam);
|
||||
|
||||
float backEaseIn(float time);
|
||||
float backEaseOut(float time);
|
||||
float backEaseInOut(float time);
|
||||
|
||||
float bounceEaseIn(float time);
|
||||
float bounceEaseOut(float time);
|
||||
float bounceEaseInOut(float time);
|
||||
|
||||
float customEase(float time, float *easingParam);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif /*__CCTWEENFUNCTION_H__*/
|
|
@ -30,6 +30,7 @@ endif()
|
|||
set(COCOS2D_SRC
|
||||
CCAction.cpp
|
||||
CCActionCamera.cpp
|
||||
CCTweenFunction.cpp
|
||||
CCActionEase.cpp
|
||||
CCActionGrid.cpp
|
||||
CCActionGrid3D.cpp
|
||||
|
|
|
@ -51,6 +51,7 @@ THE SOFTWARE.
|
|||
#include "CCActionInstant.h"
|
||||
#include "CCActionTween.h"
|
||||
#include "CCActionCatmullRom.h"
|
||||
#include "CCTweenFunction.h"
|
||||
|
||||
// base_nodes
|
||||
#include "CCNode.h"
|
||||
|
|
|
@ -299,6 +299,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClCompile Include="CCTransitionPageTurn.cpp" />
|
||||
<ClCompile Include="CCTransitionProgress.cpp" />
|
||||
<ClCompile Include="ccTypes.cpp" />
|
||||
<ClCompile Include="CCTweenFunction.cpp" />
|
||||
<ClCompile Include="CCUserDefault.cpp" />
|
||||
<ClCompile Include="ccUTF8.cpp" />
|
||||
<ClCompile Include="ccUtils.cpp" />
|
||||
|
@ -497,6 +498,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClInclude Include="CCTransitionPageTurn.h" />
|
||||
<ClInclude Include="CCTransitionProgress.h" />
|
||||
<ClInclude Include="ccTypes.h" />
|
||||
<ClInclude Include="CCTweenFunction.h" />
|
||||
<ClInclude Include="CCUserDefault.h" />
|
||||
<ClInclude Include="ccUTF8.h" />
|
||||
<ClInclude Include="ccUtils.h" />
|
||||
|
|
|
@ -6,7 +6,6 @@ LOCAL_MODULE := cocostudio_static
|
|||
LOCAL_MODULE_FILENAME := libcocostudio
|
||||
|
||||
LOCAL_SRC_FILES := CCActionFrame.cpp \
|
||||
CCActionEaseEx.cpp \
|
||||
CCActionFrameEasing.cpp \
|
||||
CCActionManagerEx.cpp \
|
||||
CCActionNode.cpp \
|
||||
|
@ -28,7 +27,6 @@ CCArmatureDefine.cpp \
|
|||
CCDataReaderHelper.cpp \
|
||||
CCSpriteFrameCacheHelper.cpp \
|
||||
CCTransformHelp.cpp \
|
||||
CCTweenFunction.cpp \
|
||||
CCUtilMath.cpp \
|
||||
CCComAttribute.cpp \
|
||||
CCComAudio.cpp \
|
||||
|
|
|
@ -1,749 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
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 "CCActionEaseEx.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
static inline float bezieratFunction( float a, float b, float c, float d, float t )
|
||||
{
|
||||
return (powf(1-t,3) * a + 3*t*(powf(1-t,2))*b + 3*powf(t,2)*(1-t)*c + powf(t,3)*d );
|
||||
}
|
||||
|
||||
EaseBezierAction* EaseBezierAction::create(cocos2d::ActionInterval* action)
|
||||
{
|
||||
EaseBezierAction *ret = new EaseBezierAction();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EaseBezierAction::setBezierParamer( float p0, float p1, float p2, float p3)
|
||||
{
|
||||
_p0 = p0;
|
||||
_p1 = p1;
|
||||
_p2 = p2;
|
||||
_p3 = p3;
|
||||
}
|
||||
|
||||
EaseBezierAction* EaseBezierAction::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseBezierAction();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->setBezierParamer(_p0,_p1,_p2,_p3);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseBezierAction::update(float time)
|
||||
{
|
||||
_inner->update(bezieratFunction(_p0,_p1,_p2,_p3,time));
|
||||
}
|
||||
|
||||
EaseBezierAction* EaseBezierAction::reverse() const
|
||||
{
|
||||
EaseBezierAction* reverseAction = EaseBezierAction::create(_inner->reverse());
|
||||
reverseAction->setBezierParamer(_p3,_p2,_p1,_p0);
|
||||
return reverseAction;
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuadraticActionIn
|
||||
//
|
||||
|
||||
EaseQuadraticActionIn* EaseQuadraticActionIn::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuadraticActionIn *ret = new EaseQuadraticActionIn();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuadraticActionIn* EaseQuadraticActionIn::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuadraticActionIn();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
void EaseQuadraticActionIn::update(float time)
|
||||
{
|
||||
_inner->update(powf(time,2));
|
||||
}
|
||||
|
||||
EaseQuadraticActionIn* EaseQuadraticActionIn::reverse() const
|
||||
{
|
||||
return EaseQuadraticActionIn::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuadraticActionOut
|
||||
//
|
||||
|
||||
EaseQuadraticActionOut* EaseQuadraticActionOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuadraticActionOut *ret = new EaseQuadraticActionOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuadraticActionOut* EaseQuadraticActionOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuadraticActionOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuadraticActionOut::update(float time)
|
||||
{
|
||||
_inner->update(-time*(time-2));
|
||||
}
|
||||
|
||||
EaseQuadraticActionOut* EaseQuadraticActionOut::reverse() const
|
||||
{
|
||||
return EaseQuadraticActionOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuadraticActionInOut
|
||||
//
|
||||
|
||||
EaseQuadraticActionInOut* EaseQuadraticActionInOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuadraticActionInOut *ret = new EaseQuadraticActionInOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuadraticActionInOut* EaseQuadraticActionInOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuadraticActionInOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuadraticActionInOut::update(float time)
|
||||
{
|
||||
float resultTime = time;
|
||||
time = time*2;
|
||||
if (time < 1)
|
||||
{
|
||||
resultTime = time * time * 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
--time;
|
||||
resultTime = -0.5f * (time * (time - 2) - 1);
|
||||
}
|
||||
|
||||
_inner->update(resultTime);
|
||||
}
|
||||
|
||||
EaseQuadraticActionInOut* EaseQuadraticActionInOut::reverse() const
|
||||
{
|
||||
return EaseQuadraticActionInOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuarticActionIn
|
||||
//
|
||||
|
||||
EaseQuarticActionIn* EaseQuarticActionIn::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuarticActionIn *ret = new EaseQuarticActionIn();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuarticActionIn* EaseQuarticActionIn::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuarticActionIn();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuarticActionIn::update(float time)
|
||||
{
|
||||
_inner->update(powf(time,4.0f));
|
||||
}
|
||||
|
||||
EaseQuarticActionIn* EaseQuarticActionIn::reverse() const
|
||||
{
|
||||
return EaseQuarticActionIn::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuarticActionOut
|
||||
//
|
||||
|
||||
EaseQuarticActionOut* EaseQuarticActionOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuarticActionOut *ret = new EaseQuarticActionOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuarticActionOut* EaseQuarticActionOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuarticActionOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuarticActionOut::update(float time)
|
||||
{
|
||||
float tempTime = time -1;
|
||||
_inner->update(1- powf(tempTime,4.0f));
|
||||
}
|
||||
|
||||
EaseQuarticActionOut* EaseQuarticActionOut::reverse() const
|
||||
{
|
||||
return EaseQuarticActionOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuarticActionInOut
|
||||
//
|
||||
|
||||
EaseQuarticActionInOut* EaseQuarticActionInOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuarticActionInOut *ret = new EaseQuarticActionInOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuarticActionInOut* EaseQuarticActionInOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuarticActionInOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuarticActionInOut::update(float time)
|
||||
{
|
||||
float tempTime = time * 2;
|
||||
if (tempTime < 1)
|
||||
tempTime = powf(tempTime,4.0f) * 0.5f;
|
||||
else
|
||||
{
|
||||
tempTime -= 2;
|
||||
tempTime = 1 - powf(tempTime,4.0f)* 0.5f;
|
||||
}
|
||||
|
||||
_inner->update(tempTime);
|
||||
}
|
||||
|
||||
EaseQuarticActionInOut* EaseQuarticActionInOut::reverse() const
|
||||
{
|
||||
return EaseQuarticActionInOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuinticActionIn
|
||||
//
|
||||
|
||||
EaseQuinticActionIn* EaseQuinticActionIn::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuinticActionIn *ret = new EaseQuinticActionIn();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuinticActionIn* EaseQuinticActionIn::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuinticActionIn();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuinticActionIn::update(float time)
|
||||
{
|
||||
_inner->update(powf(time,5.0f));
|
||||
}
|
||||
|
||||
EaseQuinticActionIn* EaseQuinticActionIn::reverse() const
|
||||
{
|
||||
return EaseQuinticActionIn::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuinticActionOut
|
||||
//
|
||||
|
||||
EaseQuinticActionOut* EaseQuinticActionOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuinticActionOut *ret = new EaseQuinticActionOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuinticActionOut* EaseQuinticActionOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuinticActionOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuinticActionOut::update(float time)
|
||||
{
|
||||
float tempTime = time -1;
|
||||
_inner->update(1 + powf(tempTime,5.0f));
|
||||
}
|
||||
|
||||
EaseQuinticActionOut* EaseQuinticActionOut::reverse() const
|
||||
{
|
||||
return EaseQuinticActionOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseQuinticActionInOut
|
||||
//
|
||||
|
||||
EaseQuinticActionInOut* EaseQuinticActionInOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseQuinticActionInOut *ret = new EaseQuinticActionInOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseQuinticActionInOut* EaseQuinticActionInOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseQuinticActionInOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseQuinticActionInOut::update(float time)
|
||||
{
|
||||
float tempTime = time * 2;
|
||||
if (tempTime < 1)
|
||||
tempTime = powf(tempTime,5.0f) * 0.5f;
|
||||
else
|
||||
{
|
||||
tempTime -= 2;
|
||||
tempTime = 1 + powf(tempTime,5.0f)* 0.5f;
|
||||
}
|
||||
|
||||
_inner->update(tempTime);
|
||||
}
|
||||
|
||||
EaseQuinticActionInOut* EaseQuinticActionInOut::reverse() const
|
||||
{
|
||||
return EaseQuinticActionInOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCircleActionIn
|
||||
//
|
||||
|
||||
EaseCircleActionIn* EaseCircleActionIn::create(ActionInterval* action)
|
||||
{
|
||||
EaseCircleActionIn *ret = new EaseCircleActionIn();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCircleActionIn* EaseCircleActionIn::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCircleActionIn();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCircleActionIn::update(float time)
|
||||
{
|
||||
_inner->update(1-sqrt(1-powf(time,2.0f)));
|
||||
}
|
||||
|
||||
EaseCircleActionIn* EaseCircleActionIn::reverse() const
|
||||
{
|
||||
return EaseCircleActionIn::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCircleActionOut
|
||||
//
|
||||
|
||||
EaseCircleActionOut* EaseCircleActionOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseCircleActionOut *ret = new EaseCircleActionOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCircleActionOut* EaseCircleActionOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCircleActionOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCircleActionOut::update(float time)
|
||||
{
|
||||
float tempTime = time - 1;
|
||||
_inner->update(sqrt(1-powf(tempTime,2.0f)));
|
||||
}
|
||||
|
||||
EaseCircleActionOut* EaseCircleActionOut::reverse() const
|
||||
{
|
||||
return EaseCircleActionOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCircleActionInOut
|
||||
//
|
||||
|
||||
EaseCircleActionInOut* EaseCircleActionInOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseCircleActionInOut *ret = new EaseCircleActionInOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCircleActionInOut* EaseCircleActionInOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCircleActionInOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCircleActionInOut::update(float time)
|
||||
{
|
||||
float tempTime = time * 2;
|
||||
if (tempTime < 1)
|
||||
tempTime = (1- sqrt(1 - powf(tempTime,2.0f))) * 0.5f;
|
||||
else
|
||||
{
|
||||
tempTime -= 2;
|
||||
tempTime = (1+ sqrt(1 - powf(tempTime,2.0f))) * 0.5f;
|
||||
}
|
||||
|
||||
_inner->update(time);
|
||||
}
|
||||
|
||||
EaseCircleActionInOut* EaseCircleActionInOut::reverse() const
|
||||
{
|
||||
return EaseCircleActionInOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCubicActionIn
|
||||
//
|
||||
|
||||
EaseCubicActionIn* EaseCubicActionIn::create(ActionInterval* action)
|
||||
{
|
||||
EaseCubicActionIn *ret = new EaseCubicActionIn();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCubicActionIn* EaseCubicActionIn::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCubicActionIn();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCubicActionIn::update(float time)
|
||||
{
|
||||
_inner->update(powf(time,3.0f));
|
||||
}
|
||||
|
||||
EaseCubicActionIn* EaseCubicActionIn::reverse() const
|
||||
{
|
||||
return EaseCubicActionIn::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCubicActionOut
|
||||
//
|
||||
|
||||
EaseCubicActionOut* EaseCubicActionOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseCubicActionOut *ret = new EaseCubicActionOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCubicActionOut* EaseCubicActionOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCubicActionOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCubicActionOut::update(float time)
|
||||
{
|
||||
time -= 1;
|
||||
_inner->update(1+powf(time,3.0f));
|
||||
}
|
||||
|
||||
EaseCubicActionOut* EaseCubicActionOut::reverse() const
|
||||
{
|
||||
return EaseCubicActionOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
//
|
||||
// EaseCubicActionInOut
|
||||
//
|
||||
|
||||
EaseCubicActionInOut* EaseCubicActionInOut::create(ActionInterval* action)
|
||||
{
|
||||
EaseCubicActionInOut *ret = new EaseCubicActionInOut();
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithAction(action))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EaseCubicActionInOut* EaseCubicActionInOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new EaseCubicActionInOut();
|
||||
a->initWithAction(_inner->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void EaseCubicActionInOut::update(float time)
|
||||
{
|
||||
float tempTime = time * 2;
|
||||
if (tempTime < 1)
|
||||
tempTime = powf(tempTime,3.0f) * 0.5f;
|
||||
else
|
||||
{
|
||||
tempTime -= 2;
|
||||
tempTime = 1 + powf(tempTime,3.0f)* 0.5f;
|
||||
}
|
||||
_inner->update(time);
|
||||
}
|
||||
|
||||
EaseCubicActionInOut* EaseCubicActionInOut::reverse() const
|
||||
{
|
||||
return EaseCubicActionInOut::create(_inner->reverse());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,396 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ActionEaseEx_H__
|
||||
#define __ActionEaseEx_H__
|
||||
|
||||
#include "cocostudio/CocoStudio.h"
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
/**
|
||||
@brief Ease Bezier
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseBezierAction : public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseBezierAction* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseBezierAction* clone() const override;
|
||||
virtual EaseBezierAction* reverse() const override;
|
||||
|
||||
virtual void setBezierParamer( float p0, float p1, float p2, float p3);
|
||||
|
||||
protected:
|
||||
EaseBezierAction() {}
|
||||
virtual ~EaseBezierAction() {}
|
||||
|
||||
float _p0;
|
||||
float _p1;
|
||||
float _p2;
|
||||
float _p3;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseBezierAction);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quadratic In
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuadraticActionIn:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuadraticActionIn* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuadraticActionIn* clone() const override;
|
||||
virtual EaseQuadraticActionIn* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuadraticActionIn() {}
|
||||
virtual ~EaseQuadraticActionIn() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuadraticActionIn);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quadratic Out
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuadraticActionOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuadraticActionOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuadraticActionOut* clone() const override;
|
||||
virtual EaseQuadraticActionOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuadraticActionOut() {}
|
||||
virtual ~EaseQuadraticActionOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuadraticActionOut);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quadratic InOut
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuadraticActionInOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuadraticActionInOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuadraticActionInOut* clone() const override;
|
||||
virtual EaseQuadraticActionInOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuadraticActionInOut() {}
|
||||
virtual ~EaseQuadraticActionInOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuadraticActionInOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quartic In
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuarticActionIn:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuarticActionIn* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuarticActionIn* clone() const override;
|
||||
virtual EaseQuarticActionIn* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuarticActionIn() {}
|
||||
virtual ~EaseQuarticActionIn() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuarticActionIn);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quartic Out
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuarticActionOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuarticActionOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuarticActionOut* clone() const override;
|
||||
virtual EaseQuarticActionOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuarticActionOut() {}
|
||||
virtual ~EaseQuarticActionOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuarticActionOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quartic InOut
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuarticActionInOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuarticActionInOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuarticActionInOut* clone() const override;
|
||||
virtual EaseQuarticActionInOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuarticActionInOut() {}
|
||||
virtual ~EaseQuarticActionInOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuarticActionInOut);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@brief Ease Quintic In
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuinticActionIn:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuinticActionIn* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuinticActionIn* clone() const override;
|
||||
virtual EaseQuinticActionIn* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuinticActionIn() {}
|
||||
virtual ~EaseQuinticActionIn() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuinticActionIn);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quintic Out
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuinticActionOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuinticActionOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuinticActionOut* clone() const override;
|
||||
virtual EaseQuinticActionOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuinticActionOut() {}
|
||||
virtual ~EaseQuinticActionOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuinticActionOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Quintic InOut
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseQuinticActionInOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseQuinticActionInOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseQuinticActionInOut* clone() const override;
|
||||
virtual EaseQuinticActionInOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseQuinticActionInOut() {}
|
||||
virtual ~EaseQuinticActionInOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseQuinticActionInOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Circle In
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCircleActionIn:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCircleActionIn* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCircleActionIn* clone() const override;
|
||||
virtual EaseCircleActionIn* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCircleActionIn() {}
|
||||
virtual ~EaseCircleActionIn() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCircleActionIn);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Circle Out
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCircleActionOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCircleActionOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCircleActionOut* clone() const override;
|
||||
virtual EaseCircleActionOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCircleActionOut() {}
|
||||
virtual ~EaseCircleActionOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCircleActionOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Circle InOut
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCircleActionInOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCircleActionInOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCircleActionInOut* clone() const override;
|
||||
virtual EaseCircleActionInOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCircleActionInOut() {}
|
||||
virtual ~EaseCircleActionInOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCircleActionInOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Cubic In
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCubicActionIn:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCubicActionIn* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCubicActionIn* clone() const override;
|
||||
virtual EaseCubicActionIn* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCubicActionIn() {}
|
||||
virtual ~EaseCubicActionIn() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCubicActionIn);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Cubic Out
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCubicActionOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCubicActionOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCubicActionOut* clone() const override;
|
||||
virtual EaseCubicActionOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCubicActionOut() {}
|
||||
virtual ~EaseCubicActionOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCubicActionOut);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Ease Cubic InOut
|
||||
@ingroup Actions
|
||||
*/
|
||||
class EaseCubicActionInOut:public cocos2d::ActionEase
|
||||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static EaseCubicActionInOut* create(cocos2d::ActionInterval* action);
|
||||
|
||||
virtual void update(float time) override;
|
||||
virtual EaseCubicActionInOut* clone() const override;
|
||||
virtual EaseCubicActionInOut* reverse() const override;
|
||||
|
||||
protected:
|
||||
EaseCubicActionInOut() {}
|
||||
virtual ~EaseCubicActionInOut() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(EaseCubicActionInOut);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -23,7 +23,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "CCActionFrame.h"
|
||||
#include "CCActionEaseEx.h"
|
||||
#include "CCActionEase.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
|
@ -239,7 +239,7 @@ Point ActionMoveFrame::getPosition()
|
|||
}
|
||||
ActionInterval* ActionMoveFrame::getAction(float fDuration)
|
||||
{
|
||||
return this->getEasingAction(CCMoveTo::create(fDuration,_position));
|
||||
return this->getEasingAction(MoveTo::create(fDuration,_position));
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -277,7 +277,7 @@ float ActionScaleFrame::getScaleY()
|
|||
|
||||
ActionInterval* ActionScaleFrame::getAction(float fDuration)
|
||||
{
|
||||
return this->getEasingAction(CCScaleTo::create(fDuration,_scaleX,_scaleY));
|
||||
return this->getEasingAction(ScaleTo::create(fDuration,_scaleX,_scaleY));
|
||||
}
|
||||
|
||||
ActionRotationFrame::ActionRotationFrame()
|
||||
|
@ -303,7 +303,7 @@ float ActionRotationFrame::getRotation()
|
|||
|
||||
ActionInterval* ActionRotationFrame::getAction(float fDuration)
|
||||
{
|
||||
return this->getEasingAction(CCRotateTo::create(fDuration,_rotation));
|
||||
return this->getEasingAction(RotateTo::create(fDuration,_rotation));
|
||||
}
|
||||
ActionInterval* ActionRotationFrame::getAction(float fDuration,ActionFrame* srcFrame)
|
||||
{
|
||||
|
@ -315,7 +315,7 @@ ActionInterval* ActionRotationFrame::getAction(float fDuration,ActionFrame* srcF
|
|||
else
|
||||
{
|
||||
float diffRotation = _rotation - srcRotationFrame->_rotation;
|
||||
return this->getEasingAction(CCRotateBy::create(fDuration,diffRotation));
|
||||
return this->getEasingAction(RotateBy::create(fDuration,diffRotation));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ int ActionFadeFrame::getOpacity()
|
|||
|
||||
ActionInterval* ActionFadeFrame::getAction(float fDuration)
|
||||
{
|
||||
return this->getEasingAction(CCFadeTo::create(fDuration,_opacity));
|
||||
return this->getEasingAction(FadeTo::create(fDuration,_opacity));
|
||||
}
|
||||
|
||||
|
||||
|
@ -369,7 +369,7 @@ Color3B ActionTintFrame::getColor()
|
|||
|
||||
ActionInterval* ActionTintFrame::getAction(float fDuration)
|
||||
{
|
||||
return this->getEasingAction(CCTintTo::create(fDuration,_color.r,_color.g,_color.b));
|
||||
return this->getEasingAction(TintTo::create(fDuration,_color.r,_color.g,_color.b));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,13 +59,12 @@ CC_DEPRECATED_ATTRIBUTE typedef DisplayManager CCDisplayManager;
|
|||
CC_DEPRECATED_ATTRIBUTE typedef ColliderBody CCColliderBody;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ColliderDetector CCColliderDetector;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef SpriteFrameCacheHelper CCSpriteFrameCacheHelper;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef TweenFunction CCTweenFunction;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ArmatureData CCArmatureData;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Bone CCBone;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ArmatureAnimation CCArmatureAnimation;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Armature CCArmature;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ArmatureDataManager CCArmatureDataManager;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef TweenType CCTweenType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef cocos2d::tweenfunc::TweenType CCTweenType;
|
||||
|
||||
class Armature : public cocos2d::Node, public cocos2d::BlendProtocol
|
||||
{
|
||||
|
|
|
@ -183,7 +183,7 @@ void ArmatureAnimation::play(const std::string& animationName, int durationTo,
|
|||
|
||||
int durationTween = _movementData->durationTween == 0 ? _rawDuration : _movementData->durationTween;
|
||||
|
||||
TweenType tweenEasing = _movementData->tweenEasing;
|
||||
cocos2d::tweenfunc::TweenType tweenEasing = _movementData->tweenEasing;
|
||||
loop = (loop < 0) ? _movementData->loop : loop;
|
||||
|
||||
_onMovementList = false;
|
||||
|
|
|
@ -743,12 +743,12 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
|
|||
{
|
||||
if( movementXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
movementData->tweenEasing = tweenEasing == 2 ? Sine_EaseInOut : (TweenType)tweenEasing;
|
||||
movementData->tweenEasing = tweenEasing == 2 ? cocos2d::tweenfunc::Sine_EaseInOut : (TweenType)tweenEasing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
movementData->tweenEasing = Linear;
|
||||
movementData->tweenEasing = cocos2d::tweenfunc::Linear;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1072,12 +1072,12 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
|
|||
{
|
||||
if( frameXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
frameData->tweenEasing = tweenEasing == 2 ? Sine_EaseInOut : (TweenType)tweenEasing;
|
||||
frameData->tweenEasing = tweenEasing == 2 ? cocos2d::tweenfunc::Sine_EaseInOut : (cocos2d::tweenfunc::TweenType)tweenEasing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
frameData->tweenEasing = Linear;
|
||||
frameData->tweenEasing = cocos2d::tweenfunc::Linear;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1461,7 +1461,7 @@ MovementData *DataReaderHelper::decodeMovement(const rapidjson::Value& json, Dat
|
|||
{
|
||||
movementData->scale = DICTOOL->getFloatValue_json(json, A_MOVEMENT_SCALE, 1.0f);
|
||||
}
|
||||
movementData->tweenEasing = (TweenType)(DICTOOL->getIntValue_json(json, A_TWEEN_EASING, Linear));
|
||||
movementData->tweenEasing = (TweenType)(DICTOOL->getIntValue_json(json, A_TWEEN_EASING, cocos2d::tweenfunc::Linear));
|
||||
|
||||
const char *name = DICTOOL->getStringValue_json(json, A_NAME);
|
||||
if(name != nullptr)
|
||||
|
@ -1557,7 +1557,7 @@ FrameData *DataReaderHelper::decodeFrame(const rapidjson::Value& json, DataInfo
|
|||
|
||||
decodeNode(frameData, json, dataInfo);
|
||||
|
||||
frameData->tweenEasing = (TweenType)(DICTOOL->getIntValue_json(json, A_TWEEN_EASING, Linear));
|
||||
frameData->tweenEasing = (TweenType)(DICTOOL->getIntValue_json(json, A_TWEEN_EASING, cocos2d::tweenfunc::Linear));
|
||||
frameData->displayIndex = DICTOOL->getIntValue_json(json, A_DISPLAY_INDEX);
|
||||
frameData->blendFunc.src = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_SRC, BlendFunc::ALPHA_NON_PREMULTIPLIED.src));
|
||||
frameData->blendFunc.dst = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_DST, BlendFunc::ALPHA_NON_PREMULTIPLIED.dst));
|
||||
|
|
|
@ -249,7 +249,7 @@ BoneData *ArmatureData::getBoneData(const std::string& boneName)
|
|||
FrameData::FrameData(void)
|
||||
: frameID(0)
|
||||
, duration(1)
|
||||
, tweenEasing(Linear)
|
||||
, tweenEasing(cocos2d::tweenfunc::Linear)
|
||||
, easingParamNumber(0)
|
||||
, easingParams(NULL)
|
||||
, isTween(true)
|
||||
|
@ -330,7 +330,7 @@ MovementData::MovementData(void)
|
|||
, durationTo(0)
|
||||
, durationTween(0)
|
||||
, loop(true)
|
||||
, tweenEasing(Linear)
|
||||
, tweenEasing(cocos2d::tweenfunc::Linear)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ THE SOFTWARE.
|
|||
#include "CCAffineTransform.h"
|
||||
#include "CCNode.h"
|
||||
#include "cocostudio/CCArmatureDefine.h"
|
||||
#include "cocostudio/CCTweenFunction.h"
|
||||
#include "CCTweenFunction.h"
|
||||
|
||||
|
||||
#define CC_CREATE_NO_PARAM_NO_INIT(varType)\
|
||||
|
@ -334,7 +334,7 @@ public:
|
|||
int frameID;
|
||||
int duration; //! The frame will last duration frames
|
||||
|
||||
TweenType tweenEasing; //! Every frame's tween easing effect
|
||||
cocos2d::tweenfunc::TweenType tweenEasing; //! Every frame's tween easing effect
|
||||
int easingParamNumber;
|
||||
float *easingParams;
|
||||
|
||||
|
@ -437,7 +437,7 @@ public:
|
|||
* Which tween easing effect the movement use
|
||||
* TWEEN_EASING_MAX : use the value from MovementData get from flash design panel
|
||||
*/
|
||||
TweenType tweenEasing;
|
||||
cocos2d::tweenfunc::TweenType tweenEasing;
|
||||
|
||||
/**
|
||||
* @brief save movment bone data
|
||||
|
|
|
@ -37,7 +37,7 @@ ProcessBase::ProcessBase(void)
|
|||
, _currentPercent(0.0f)
|
||||
, _rawDuration(0)
|
||||
, _loopType(ANIMATION_LOOP_BACK)
|
||||
, _tweenEasing(Linear)
|
||||
, _tweenEasing(cocos2d::tweenfunc::Linear)
|
||||
, _animationInternal(1/60.0f)
|
||||
, _durationTween(0)
|
||||
, _currentFrame(0)
|
||||
|
@ -83,7 +83,7 @@ void ProcessBase::play(int durationTo, int durationTween, int loop, int tweenEa
|
|||
* When changing end, m_iTotalFrames will be setted to _durationTween
|
||||
*/
|
||||
_nextFrameIndex = durationTo;
|
||||
_tweenEasing = (TweenType)tweenEasing;
|
||||
_tweenEasing = (cocos2d::tweenfunc::TweenType)tweenEasing;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ THE SOFTWARE.
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
|
||||
enum AnimationType
|
||||
{
|
||||
SINGLE_FRAME = -4, //! the animation just have one frame
|
||||
|
@ -155,7 +156,7 @@ protected:
|
|||
AnimationType _loopType;
|
||||
|
||||
//! The tween easing effect
|
||||
TweenType _tweenEasing;
|
||||
cocos2d::tweenfunc::TweenType _tweenEasing;
|
||||
|
||||
//! The animation update speed
|
||||
float _animationInternal;
|
||||
|
|
|
@ -28,12 +28,13 @@ THE SOFTWARE.
|
|||
#include "cocostudio/CCBone.h"
|
||||
#include "cocostudio/CCArmature.h"
|
||||
#include "cocostudio/CCUtilMath.h"
|
||||
#include "cocostudio/CCTweenFunction.h"
|
||||
#include "cocostudio/CCTransformHelp.h"
|
||||
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
using cocos2d::tweenfunc::Linear;
|
||||
|
||||
Tween *Tween::create(Bone *bone)
|
||||
{
|
||||
Tween *pTween = new Tween();
|
||||
|
@ -281,7 +282,7 @@ void Tween::updateHandler()
|
|||
percent = updateFrameData(percent);
|
||||
}
|
||||
|
||||
if(_frameTweenEasing != TWEEN_EASING_MAX)
|
||||
if(_frameTweenEasing != ::cocos2d::tweenfunc::TWEEN_EASING_MAX)
|
||||
{
|
||||
tweenNodeTo(percent);
|
||||
}
|
||||
|
@ -475,9 +476,9 @@ float Tween::updateFrameData(float currentPercent)
|
|||
* If frame tween easing equal to TWEEN_EASING_MAX, then it will not do tween.
|
||||
*/
|
||||
TweenType tweenType = (_frameTweenEasing != Linear) ? _frameTweenEasing : _tweenEasing;
|
||||
if (tweenType != TWEEN_EASING_MAX && tweenType != Linear && !_passLastFrame)
|
||||
if (tweenType != cocos2d::tweenfunc::TWEEN_EASING_MAX && tweenType != Linear && !_passLastFrame)
|
||||
{
|
||||
currentPercent = TweenFunction::tweenTo(currentPercent, tweenType, _from->easingParams);
|
||||
currentPercent = cocos2d::tweenfunc::tweenTo(currentPercent, tweenType, _from->easingParams);
|
||||
}
|
||||
|
||||
return currentPercent;
|
||||
|
|
|
@ -27,12 +27,13 @@ THE SOFTWARE.
|
|||
#define __CCTWEEN_H__
|
||||
|
||||
#include "cocostudio/CCProcessBase.h"
|
||||
#include "cocostudio/CCTweenFunction.h"
|
||||
#include "CCTweenFunction.h"
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
class Bone;
|
||||
class ArmatureAnimation;
|
||||
using cocos2d::tweenfunc::TweenType;
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
|
|
|
@ -1,141 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCTWEENFUNCTION_H__
|
||||
#define __CCTWEENFUNCTION_H__
|
||||
|
||||
|
||||
#include "cocostudio/CCArmatureDefine.h"
|
||||
#include <math.h>
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
enum TweenType
|
||||
{
|
||||
CUSTOM_EASING = -1,
|
||||
|
||||
Linear,
|
||||
|
||||
Sine_EaseIn,
|
||||
Sine_EaseOut,
|
||||
Sine_EaseInOut,
|
||||
|
||||
|
||||
Quad_EaseIn,
|
||||
Quad_EaseOut,
|
||||
Quad_EaseInOut,
|
||||
|
||||
Cubic_EaseIn,
|
||||
Cubic_EaseOut,
|
||||
Cubic_EaseInOut,
|
||||
|
||||
Quart_EaseIn,
|
||||
Quart_EaseOut,
|
||||
Quart_EaseInOut,
|
||||
|
||||
Quint_EaseIn,
|
||||
Quint_EaseOut,
|
||||
Quint_EaseInOut,
|
||||
|
||||
Expo_EaseIn,
|
||||
Expo_EaseOut,
|
||||
Expo_EaseInOut,
|
||||
|
||||
Circ_EaseIn,
|
||||
Circ_EaseOut,
|
||||
Circ_EaseInOut,
|
||||
|
||||
Elastic_EaseIn,
|
||||
Elastic_EaseOut,
|
||||
Elastic_EaseInOut,
|
||||
|
||||
Back_EaseIn,
|
||||
Back_EaseOut,
|
||||
Back_EaseInOut,
|
||||
|
||||
Bounce_EaseIn,
|
||||
Bounce_EaseOut,
|
||||
Bounce_EaseInOut,
|
||||
|
||||
TWEEN_EASING_MAX = 10000
|
||||
};
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
class TweenFunction
|
||||
{
|
||||
public:
|
||||
|
||||
static float tweenTo(float time, TweenType type, float *easingParam);
|
||||
|
||||
static float linear(float time);
|
||||
|
||||
static float sineEaseIn(float time);
|
||||
static float sineEaseOut(float time);
|
||||
static float sineEaseInOut(float time);
|
||||
|
||||
static float quadEaseIn(float time);
|
||||
static float quadEaseOut(float time);
|
||||
static float quadEaseInOut(float time);
|
||||
|
||||
static float cubicEaseIn(float time);
|
||||
static float cubicEaseOut(float time);
|
||||
static float cubicEaseInOut(float time);
|
||||
|
||||
static float quartEaseIn(float time);
|
||||
static float quartEaseOut(float time);
|
||||
static float quartEaseInOut(float time);
|
||||
|
||||
static float quintEaseIn(float time);
|
||||
static float quintEaseOut(float time);
|
||||
static float quintEaseInOut(float time);
|
||||
|
||||
static float expoEaseIn(float time);
|
||||
static float expoEaseOut(float time);
|
||||
static float expoEaseInOut(float time);
|
||||
|
||||
static float circEaseIn(float time);
|
||||
static float circEaseOut(float time);
|
||||
static float circEaseInOut(float time);
|
||||
|
||||
static float elasticEaseIn(float time, float *easingParam);
|
||||
static float elasticEaseOut(float time, float *easingParam);
|
||||
static float elasticEaseInOut(float time, float *easingParam);
|
||||
|
||||
static float backEaseIn(float time);
|
||||
static float backEaseOut(float time);
|
||||
static float backEaseInOut(float time);
|
||||
|
||||
static float bounceEaseIn(float time);
|
||||
static float bounceEaseOut(float time);
|
||||
static float bounceEaseInOut(float time);
|
||||
|
||||
static float customEase(float time, float *easingParam);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif /*__CCTWEENFUNCTION_H__*/
|
|
@ -1,5 +1,4 @@
|
|||
set(CS_SRC
|
||||
CCActionEaseEx.cpp
|
||||
CCActionFrame.cpp
|
||||
CCActionFrameEasing.cpp
|
||||
CCActionManagerEx.cpp
|
||||
|
@ -22,7 +21,6 @@ set(CS_SRC
|
|||
CCDataReaderHelper.cpp
|
||||
CCSpriteFrameCacheHelper.cpp
|
||||
CCTransformHelp.cpp
|
||||
CCTweenFunction.cpp
|
||||
CCUtilMath.cpp
|
||||
CCComAttribute.cpp
|
||||
CCComAudio.cpp
|
||||
|
|
|
@ -47,7 +47,6 @@ THE SOFTWARE.
|
|||
#include "cocostudio/CCDataReaderHelper.h"
|
||||
#include "cocostudio/CCSpriteFrameCacheHelper.h"
|
||||
#include "cocostudio/CCTransformHelp.h"
|
||||
#include "cocostudio/CCTweenFunction.h"
|
||||
#include "cocostudio/CCUtilMath.h"
|
||||
#include "cocostudio/CCComBase.h"
|
||||
#include "cocostudio/CCComAttribute.h"
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\CCActionEaseEx.cpp" />
|
||||
<ClCompile Include="..\CCActionFrame.cpp" />
|
||||
<ClCompile Include="..\CCActionFrameEasing.cpp" />
|
||||
<ClCompile Include="..\CCActionManagerEx.cpp" />
|
||||
|
@ -41,7 +40,6 @@
|
|||
<ClCompile Include="..\CCSSceneReader.cpp" />
|
||||
<ClCompile Include="..\CCTransformHelp.cpp" />
|
||||
<ClCompile Include="..\CCTween.cpp" />
|
||||
<ClCompile Include="..\CCTweenFunction.cpp" />
|
||||
<ClCompile Include="..\CCUtilMath.cpp" />
|
||||
<ClCompile Include="..\DictionaryHelper.cpp" />
|
||||
<ClCompile Include="..\ObjectFactory.cpp" />
|
||||
|
@ -60,7 +58,6 @@
|
|||
<ClInclude Include="..\..\..\..\external\json\reader.h" />
|
||||
<ClInclude Include="..\..\..\..\external\json\stringbuffer.h" />
|
||||
<ClInclude Include="..\..\..\..\external\json\writer.h" />
|
||||
<ClInclude Include="..\CCActionEaseEx.h" />
|
||||
<ClInclude Include="..\CCActionFrame.h" />
|
||||
<ClInclude Include="..\CCActionFrameEasing.h" />
|
||||
<ClInclude Include="..\CCActionManagerEx.h" />
|
||||
|
@ -91,7 +88,6 @@
|
|||
<ClInclude Include="..\CCSSceneReader.h" />
|
||||
<ClInclude Include="..\CCTransformHelp.h" />
|
||||
<ClInclude Include="..\CCTween.h" />
|
||||
<ClInclude Include="..\CCTweenFunction.h" />
|
||||
<ClInclude Include="..\CCUtilMath.h" />
|
||||
<ClInclude Include="..\DictionaryHelper.h" />
|
||||
<ClInclude Include="..\ObjectFactory.h" />
|
||||
|
@ -178,4 +174,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -123,9 +123,6 @@
|
|||
<ClCompile Include="..\CCBone.cpp">
|
||||
<Filter>armature</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\CCActionEaseEx.cpp">
|
||||
<Filter>action</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\CCActionFrame.cpp">
|
||||
<Filter>action</Filter>
|
||||
</ClCompile>
|
||||
|
@ -266,9 +263,6 @@
|
|||
<ClInclude Include="..\..\..\..\external\json\internal\strfunc.h">
|
||||
<Filter>json\rapidjson\internal</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\CCActionEaseEx.h">
|
||||
<Filter>action</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\CCActionFrame.h">
|
||||
<Filter>action</Filter>
|
||||
</ClInclude>
|
||||
|
@ -300,4 +294,4 @@
|
|||
<Filter>components</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -36,6 +36,42 @@ Layer* nextEaseAction();
|
|||
Layer* backEaseAction();
|
||||
Layer* restartEaseAction();
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteDemo
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
void EaseSpriteDemo::centerSprites(unsigned int numberOfSprites)
|
||||
{
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
if( numberOfSprites == 0 )
|
||||
{
|
||||
_tamara->setVisible(false);
|
||||
_kathia->setVisible(false);
|
||||
_grossini->setVisible(false);
|
||||
}
|
||||
else if ( numberOfSprites == 1 )
|
||||
{
|
||||
_tamara->setVisible(false);
|
||||
_kathia->setVisible(false);
|
||||
_grossini->setPosition(Point(s.width/2, s.height/2));
|
||||
}
|
||||
else if( numberOfSprites == 2 )
|
||||
{
|
||||
_kathia->setPosition( Point(s.width/3, s.height/2));
|
||||
_tamara->setPosition( Point(2*s.width/3, s.height/2));
|
||||
_grossini->setVisible(false);
|
||||
}
|
||||
else if( numberOfSprites == 3 )
|
||||
{
|
||||
_grossini->setPosition( Point(s.width/2, s.height/2));
|
||||
_tamara->setPosition( Point(s.width/4, s.height/2));
|
||||
_kathia->setPosition( Point(3 * s.width/4, s.height/2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEase
|
||||
|
@ -74,6 +110,7 @@ void SpriteEase::onEnter()
|
|||
schedule(schedule_selector(SpriteEase::testStopAction), 6.25f);
|
||||
}
|
||||
|
||||
|
||||
void SpriteEase::testStopAction(float dt)
|
||||
{
|
||||
unschedule(schedule_selector(SpriteEase::testStopAction));
|
||||
|
@ -479,6 +516,406 @@ std::string SpriteEaseBackInOut::title() const
|
|||
return "EaseBackInOut action";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEaseBezier
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void SpriteEaseBezier::onEnter()
|
||||
{
|
||||
EaseSpriteDemo::onEnter();
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
//
|
||||
// startPosition can be any coordinate, but since the movement
|
||||
// is relative to the Bezier curve, make it (0,0)
|
||||
//
|
||||
|
||||
centerSprites(3);
|
||||
|
||||
// sprite 1
|
||||
ccBezierConfig bezier;
|
||||
bezier.controlPoint_1 = Point(0, s.height/2);
|
||||
bezier.controlPoint_2 = Point(300, -s.height/2);
|
||||
bezier.endPosition = Point(300,100);
|
||||
|
||||
auto bezierForward = BezierBy::create(3, bezier);
|
||||
auto bezierEaseForward = EaseBezierAction::create(bezierForward);
|
||||
bezierEaseForward->setBezierParamer(0.5, 0.5, 1.0, 1.0);
|
||||
|
||||
auto bezierEaseBack = bezierEaseForward->reverse();
|
||||
auto rep = RepeatForever::create(Sequence::create( bezierEaseForward, bezierEaseBack, NULL));
|
||||
|
||||
|
||||
// sprite 2
|
||||
_tamara->setPosition(Point(80,160));
|
||||
ccBezierConfig bezier2;
|
||||
bezier2.controlPoint_1 = Point(100, s.height/2);
|
||||
bezier2.controlPoint_2 = Point(200, -s.height/2);
|
||||
bezier2.endPosition = Point(240,160);
|
||||
|
||||
auto bezierTo1 = BezierTo::create(2, bezier2);
|
||||
auto bezierEaseTo1 = EaseBezierAction::create(bezierTo1);
|
||||
bezierEaseTo1->setBezierParamer(0.5, 0.5, 1.0, 1.0);
|
||||
|
||||
// sprite 3
|
||||
_kathia->setPosition(Point(400,160));
|
||||
auto bezierTo2 = BezierTo::create(2, bezier2);
|
||||
auto bezierEaseTo2 = EaseBezierAction::create(bezierTo2);
|
||||
bezierEaseTo2->setBezierParamer(0.0, 0.5, -5.0, 1.0);
|
||||
|
||||
|
||||
_grossini->runAction( rep);
|
||||
_tamara->runAction(bezierEaseTo1);
|
||||
_kathia->runAction(bezierTo2);
|
||||
|
||||
}
|
||||
|
||||
std::string SpriteEaseBezier::title()const
|
||||
{
|
||||
return "SpriteEaseBezier action";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEaseQuadratic
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void SpriteEaseQuadratic::onEnter()
|
||||
{
|
||||
EaseSpriteDemo::onEnter();
|
||||
|
||||
auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
||||
auto move_back = move->reverse();
|
||||
|
||||
auto move_ease_in = EaseQuadraticActionIn::create(move->clone() );
|
||||
auto move_ease_in_back = move_ease_in->reverse();
|
||||
|
||||
auto move_ease_out = EaseQuadraticActionOut::create(move->clone() );
|
||||
auto move_ease_out_back = move_ease_out->reverse();
|
||||
|
||||
auto delay = DelayTime::create(0.25f);
|
||||
|
||||
auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
||||
auto seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
|
||||
auto seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
|
||||
|
||||
_grossini->runAction( RepeatForever::create(seq1));
|
||||
_tamara->runAction( RepeatForever::create(seq2));
|
||||
_kathia->runAction( RepeatForever::create(seq3));
|
||||
}
|
||||
|
||||
std::string SpriteEaseQuadratic::title() const
|
||||
{
|
||||
return "SpriteEaseQuadratic action";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEaseQuadraticInOut
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void SpriteEaseQuadraticInOut::onEnter()
|
||||
{
|
||||
EaseSpriteDemo::onEnter();
|
||||
|
||||
auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
||||
auto move_back = move->reverse();
|
||||
|
||||
auto move_ease = EaseQuadraticActionInOut::create(move->clone() );
|
||||
auto move_ease_back = move_ease->reverse();
|
||||
|
||||
auto delay = DelayTime::create(0.25f);
|
||||
|
||||
auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
||||
auto seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL);
|
||||
|
||||
this->positionForTwo();
|
||||
|
||||
_grossini->runAction( RepeatForever::create(seq1));
|
||||
_tamara->runAction( RepeatForever::create(seq2));
|
||||
}
|
||||
|
||||
std::string SpriteEaseQuadraticInOut::title()const
|
||||
{
|
||||
return "SpriteEaseQuadraticInOut action";
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEaseQuartic
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void SpriteEaseQuartic::onEnter()
|
||||
{
|
||||
EaseSpriteDemo::onEnter();
|
||||
|
||||
auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
||||
auto move_back = move->reverse();
|
||||
|
||||
auto move_ease_in = EaseQuarticActionIn::create(move->clone() );
|
||||
auto move_ease_in_back = move_ease_in->reverse();
|
||||
|
||||
auto move_ease_out = EaseQuarticActionOut::create(move->clone() );
|
||||
auto move_ease_out_back = move_ease_out->reverse();
|
||||
|
||||
auto delay = DelayTime::create(0.25f);
|
||||
|
||||
auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
||||
auto seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
|
||||
auto seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
|
||||
|
||||
_grossini->runAction( RepeatForever::create(seq1));
|
||||
_tamara->runAction( RepeatForever::create(seq2));
|
||||
_kathia->runAction( RepeatForever::create(seq3));
|
||||
}
|
||||
|
||||
std::string SpriteEaseQuartic::title()const
|
||||
{
|
||||
return "SpriteEaseQuartic action";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEaseQuarticInOut
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void SpriteEaseQuarticInOut::onEnter()
|
||||
{
|
||||
EaseSpriteDemo::onEnter();
|
||||
|
||||
auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
||||
auto move_back = move->reverse();
|
||||
|
||||
auto move_ease = EaseQuarticActionInOut::create(move->clone() );
|
||||
auto move_ease_back = move_ease->reverse();
|
||||
|
||||
auto delay = DelayTime::create(0.25f);
|
||||
|
||||
auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
||||
auto seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL);
|
||||
|
||||
this->positionForTwo();
|
||||
|
||||
_grossini->runAction( RepeatForever::create(seq1));
|
||||
_tamara->runAction( RepeatForever::create(seq2));
|
||||
}
|
||||
|
||||
std::string SpriteEaseQuarticInOut::title()const
|
||||
{
|
||||
return "SpriteEaseQuarticInOut action";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEaseQuintic
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void SpriteEaseQuintic::onEnter()
|
||||
{
|
||||
EaseSpriteDemo::onEnter();
|
||||
|
||||
auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
||||
auto move_back = move->reverse();
|
||||
|
||||
auto move_ease_in = EaseQuinticActionIn::create(move->clone() );
|
||||
auto move_ease_in_back = move_ease_in->reverse();
|
||||
|
||||
auto move_ease_out = EaseQuinticActionOut::create(move->clone() );
|
||||
auto move_ease_out_back = move_ease_out->reverse();
|
||||
|
||||
auto delay = DelayTime::create(0.25f);
|
||||
|
||||
auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
||||
auto seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
|
||||
auto seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
|
||||
|
||||
_grossini->runAction( RepeatForever::create(seq1));
|
||||
_tamara->runAction( RepeatForever::create(seq2));
|
||||
_kathia->runAction( RepeatForever::create(seq3));
|
||||
}
|
||||
|
||||
std::string SpriteEaseQuintic::title()const
|
||||
{
|
||||
return "SpriteEaseQuintic action";
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEaseQuinticInOut
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void SpriteEaseQuinticInOut::onEnter()
|
||||
{
|
||||
EaseSpriteDemo::onEnter();
|
||||
|
||||
auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
||||
auto move_back = move->reverse();
|
||||
|
||||
auto move_ease = EaseQuinticActionInOut::create(move->clone() );
|
||||
auto move_ease_back = move_ease->reverse();
|
||||
|
||||
auto delay = DelayTime::create(0.25f);
|
||||
|
||||
auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
||||
auto seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL);
|
||||
|
||||
this->positionForTwo();
|
||||
|
||||
_grossini->runAction( RepeatForever::create(seq1));
|
||||
_tamara->runAction( RepeatForever::create(seq2));
|
||||
}
|
||||
|
||||
std::string SpriteEaseQuinticInOut::title()const
|
||||
{
|
||||
return "SpriteEaseQuinticInOut action";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEaseCircle
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void SpriteEaseCircle::onEnter()
|
||||
{
|
||||
EaseSpriteDemo::onEnter();
|
||||
|
||||
auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
||||
auto move_back = move->reverse();
|
||||
|
||||
auto move_ease_in = EaseCircleActionIn::create(move->clone() );
|
||||
auto move_ease_in_back = move_ease_in->reverse();
|
||||
|
||||
auto move_ease_out = EaseCircleActionOut::create(move->clone() );
|
||||
auto move_ease_out_back = move_ease_out->reverse();
|
||||
|
||||
auto delay = DelayTime::create(0.25f);
|
||||
|
||||
auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
||||
auto seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
|
||||
auto seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
|
||||
|
||||
_grossini->runAction( RepeatForever::create(seq1));
|
||||
_tamara->runAction( RepeatForever::create(seq2));
|
||||
_kathia->runAction( RepeatForever::create(seq3));
|
||||
}
|
||||
|
||||
std::string SpriteEaseCircle::title()const
|
||||
{
|
||||
return "SpriteEaseCircle action";
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEaseCircleInOut
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void SpriteEaseCircleInOut::onEnter()
|
||||
{
|
||||
EaseSpriteDemo::onEnter();
|
||||
|
||||
auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
||||
auto move_back = move->reverse();
|
||||
|
||||
auto move_ease = EaseCircleActionInOut::create(move->clone() );
|
||||
auto move_ease_back = move_ease->reverse();
|
||||
|
||||
auto delay = DelayTime::create(0.25f);
|
||||
|
||||
auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
||||
auto seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL);
|
||||
|
||||
this->positionForTwo();
|
||||
|
||||
_grossini->runAction( RepeatForever::create(seq1));
|
||||
_tamara->runAction( RepeatForever::create(seq2));
|
||||
}
|
||||
|
||||
std::string SpriteEaseCircleInOut::title()const
|
||||
{
|
||||
return "SpriteEaseCircleInOut action";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEaseCubic
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void SpriteEaseCubic::onEnter()
|
||||
{
|
||||
EaseSpriteDemo::onEnter();
|
||||
|
||||
auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
||||
auto move_back = move->reverse();
|
||||
|
||||
auto move_ease_in = EaseCubicActionIn::create(move->clone() );
|
||||
auto move_ease_in_back = move_ease_in->reverse();
|
||||
|
||||
auto move_ease_out = EaseCubicActionOut::create(move->clone() );
|
||||
auto move_ease_out_back = move_ease_out->reverse();
|
||||
|
||||
auto delay = DelayTime::create(0.25f);
|
||||
|
||||
auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
||||
auto seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL);
|
||||
auto seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL);
|
||||
|
||||
_grossini->runAction( RepeatForever::create(seq1));
|
||||
_tamara->runAction( RepeatForever::create(seq2));
|
||||
_kathia->runAction( RepeatForever::create(seq3));
|
||||
}
|
||||
|
||||
std::string SpriteEaseCubic::title()const
|
||||
{
|
||||
return "SpriteEaseCubic action";
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpriteEaseCubicInOut
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void SpriteEaseCubicInOut::onEnter()
|
||||
{
|
||||
EaseSpriteDemo::onEnter();
|
||||
|
||||
auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0));
|
||||
auto move_back = move->reverse();
|
||||
|
||||
auto move_ease = EaseCubicActionInOut::create(move->clone() );
|
||||
auto move_ease_back = move_ease->reverse();
|
||||
|
||||
auto delay = DelayTime::create(0.25f);
|
||||
|
||||
auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL);
|
||||
auto seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL);
|
||||
|
||||
this->positionForTwo();
|
||||
|
||||
_grossini->runAction( RepeatForever::create(seq1));
|
||||
_tamara->runAction( RepeatForever::create(seq2));
|
||||
}
|
||||
|
||||
std::string SpriteEaseCubicInOut::title()const
|
||||
{
|
||||
return "SpriteEaseCubicInOut action";
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// SpeedTest
|
||||
|
@ -547,7 +984,7 @@ enum
|
|||
|
||||
static int sceneIdx = -1;
|
||||
|
||||
#define MAX_LAYER 13
|
||||
#define MAX_LAYER 24
|
||||
|
||||
Layer* createEaseLayer(int nIndex)
|
||||
{
|
||||
|
@ -565,7 +1002,18 @@ Layer* createEaseLayer(int nIndex)
|
|||
case 9: return new SpriteEaseBounceInOut();
|
||||
case 10: return new SpriteEaseBack();
|
||||
case 11: return new SpriteEaseBackInOut();
|
||||
case 12: return new SpeedTest();
|
||||
case 12: return new SpriteEaseBezier();
|
||||
case 13: return new SpriteEaseQuadratic();
|
||||
case 14: return new SpriteEaseQuadraticInOut();
|
||||
case 15: return new SpriteEaseQuartic();
|
||||
case 16: return new SpriteEaseQuarticInOut();
|
||||
case 17: return new SpriteEaseQuintic();
|
||||
case 18: return new SpriteEaseQuinticInOut();
|
||||
case 19: return new SpriteEaseCircle();
|
||||
case 20: return new SpriteEaseCircleInOut();
|
||||
case 21: return new SpriteEaseCubic();
|
||||
case 22: return new SpriteEaseCubicInOut();
|
||||
case MAX_LAYER-1: return new SpeedTest();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,9 @@ public:
|
|||
|
||||
virtual std::string title() const override;
|
||||
virtual void onEnter();
|
||||
|
||||
|
||||
void centerSprites(unsigned int numberOfSprites);
|
||||
|
||||
void restartCallback(Object* sender);
|
||||
void nextCallback(Object* sender);
|
||||
void backCallback(Object* sender);
|
||||
|
@ -141,6 +143,83 @@ public:
|
|||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
class SpriteEaseBezier : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
class SpriteEaseQuadratic : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
class SpriteEaseQuadraticInOut : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
class SpriteEaseQuartic : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
class SpriteEaseQuarticInOut : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
class SpriteEaseQuintic : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
class SpriteEaseQuinticInOut : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
|
||||
class SpriteEaseCircle : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
class SpriteEaseCircleInOut : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
class SpriteEaseCubic : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
class SpriteEaseCubicInOut : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
void onEnter();
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
class SpeedTest : public EaseSpriteDemo
|
||||
{
|
||||
public:
|
||||
|
@ -156,4 +235,5 @@ public:
|
|||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1 +1 @@
|
|||
3964e888d4b32decf6c4b8cc4146336d1c9c935a
|
||||
716ec00b6d77f9f6945f9cd4f107e407bebbd668
|
Loading…
Reference in New Issue