From 82fcf939d08c7f67f3b8502414dc63b06c5c2168 Mon Sep 17 00:00:00 2001 From: andyque Date: Sat, 8 Mar 2014 21:48:44 +0800 Subject: [PATCH] fix ease elastic action error --- cocos/2d/CCActionEase.cpp | 6 +++--- cocos/2d/CCTweenFunction.cpp | 30 ++++++------------------------ cocos/2d/CCTweenFunction.h | 6 +++--- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/cocos/2d/CCActionEase.cpp b/cocos/2d/CCActionEase.cpp index 42f7d2a573..fa46945969 100644 --- a/cocos/2d/CCActionEase.cpp +++ b/cocos/2d/CCActionEase.cpp @@ -524,7 +524,7 @@ EaseElasticIn* EaseElasticIn::clone() const void EaseElasticIn::update(float time) { - _inner->update(tweenfunc::elasticEaseIn(time, NULL)); + _inner->update(tweenfunc::elasticEaseIn(time, _period)); } EaseElastic* EaseElasticIn::reverse() const @@ -570,7 +570,7 @@ EaseElasticOut* EaseElasticOut::clone() const void EaseElasticOut::update(float time) { - _inner->update(tweenfunc::elasticEaseOut(time, NULL)); + _inner->update(tweenfunc::elasticEaseOut(time, _period)); } EaseElastic* EaseElasticOut::reverse() const @@ -616,7 +616,7 @@ EaseElasticInOut* EaseElasticInOut::clone() const void EaseElasticInOut::update(float time) { - _inner->update(tweenfunc::elasticEaseInOut(time, NULL)); + _inner->update(tweenfunc::elasticEaseInOut(time, _period)); } EaseElasticInOut* EaseElasticInOut::reverse() const diff --git a/cocos/2d/CCTweenFunction.cpp b/cocos/2d/CCTweenFunction.cpp index 4d9bd8a38a..79a413dc9a 100644 --- a/cocos/2d/CCTweenFunction.cpp +++ b/cocos/2d/CCTweenFunction.cpp @@ -121,13 +121,13 @@ float tweenTo(float time, TweenType type, float *easingParam) break; case Elastic_EaseIn: - delta = elasticEaseIn(time, easingParam); + delta = elasticEaseIn(time, easingParam[0]); break; case Elastic_EaseOut: - delta = elasticEaseOut(time, easingParam); + delta = elasticEaseOut(time, easingParam[0]); break; case Elastic_EaseInOut: - delta = elasticEaseInOut(time, easingParam); + delta = elasticEaseInOut(time, easingParam[0]); break; @@ -315,14 +315,8 @@ float circEaseInOut(float time) // Elastic Ease -float elasticEaseIn(float time, float *easingParam) +float elasticEaseIn(float time, float period) { - float period = 0.3f; - - if (easingParam != NULL) - { - period = easingParam[0]; - } float newT = 0; if (time == 0 || time == 1) @@ -338,14 +332,8 @@ float elasticEaseIn(float time, float *easingParam) return newT; } -float elasticEaseOut(float time, float *easingParam) +float elasticEaseOut(float time, float period) { - float period = 0.3f; - - if (easingParam != NULL) - { - period = easingParam[0]; - } float newT = 0; if (time == 0 || time == 1) @@ -360,14 +348,8 @@ float elasticEaseOut(float time, float *easingParam) return newT; } -float elasticEaseInOut(float time, float *easingParam) +float elasticEaseInOut(float time, float period) { - float period = 0.3f; - - if (easingParam != NULL) - { - period = easingParam[0]; - } float newT = 0; if (time == 0 || time == 1) diff --git a/cocos/2d/CCTweenFunction.h b/cocos/2d/CCTweenFunction.h index f1fc22b53b..85e3ba0070 100644 --- a/cocos/2d/CCTweenFunction.h +++ b/cocos/2d/CCTweenFunction.h @@ -128,9 +128,9 @@ namespace tweenfunc { 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 elasticEaseIn(float time, float period); + float elasticEaseOut(float time, float period); + float elasticEaseInOut(float time, float period); float backEaseIn(float time); float backEaseOut(float time);