From 9abc5b7e8247afb1d8e33a9323fa35e104dabcc2 Mon Sep 17 00:00:00 2001 From: lvlong Date: Wed, 14 Jan 2015 10:40:47 +0800 Subject: [PATCH 1/2] fix bug: sequence action speed --- cocos/3d/CCAnimate3D.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos/3d/CCAnimate3D.cpp b/cocos/3d/CCAnimate3D.cpp index 0fc5d5b8a4..66e181f065 100644 --- a/cocos/3d/CCAnimate3D.cpp +++ b/cocos/3d/CCAnimate3D.cpp @@ -160,11 +160,13 @@ void Animate3D::stop() //! called every frame with it's delta time. DON'T override unless you know what you are doing. void Animate3D::step(float dt) { - ActionInterval::step(dt * _absSpeed); + ActionInterval::step(dt); } void Animate3D::update(float t) { + t *= _absSpeed; + if (_target) { if (_state == Animate3D::Animate3DState::FadeIn && _lastTime > 0.f) From 6d7b530ea16be6cdc28191e41446f192a27c0443 Mon Sep 17 00:00:00 2001 From: lvlong Date: Thu, 15 Jan 2015 11:32:28 +0800 Subject: [PATCH 2/2] fix bug: add animate3D to sequence problem. --- cocos/3d/CCAnimate3D.cpp | 13 ++++++++++--- cocos/3d/CCAnimate3D.h | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cocos/3d/CCAnimate3D.cpp b/cocos/3d/CCAnimate3D.cpp index 66e181f065..1242b38905 100644 --- a/cocos/3d/CCAnimate3D.cpp +++ b/cocos/3d/CCAnimate3D.cpp @@ -43,6 +43,7 @@ Animate3D* Animate3D::create(Animation3D* animation) animate->autorelease(); animate->setDuration(animation->getDuration()); + animate->setOriginInterval(animation->getDuration()); return animate; } @@ -58,6 +59,7 @@ Animate3D* Animate3D::create(Animation3D* animation, float fromTime, float durat animate->_start = fromTime / fullDuration; animate->_last = duration / fullDuration; animate->setDuration(duration); + animate->setOriginInterval(duration); return animate; } @@ -85,7 +87,7 @@ Animate3D* Animate3D::clone() const copy->_last = _last; copy->_playReverse = _playReverse; copy->setDuration(animate->getDuration()); - + copy->setOriginInterval(animate->getOriginInterval()); return copy; } @@ -165,8 +167,6 @@ void Animate3D::step(float dt) void Animate3D::update(float t) { - t *= _absSpeed; - if (_target) { if (_state == Animate3D::Animate3DState::FadeIn && _lastTime > 0.f) @@ -240,6 +240,7 @@ void Animate3D::setSpeed(float speed) { _absSpeed = fabsf(speed); _playReverse = speed < 0; + _duration = _originInterval / _absSpeed; } void Animate3D::setWeight(float weight) @@ -248,6 +249,11 @@ void Animate3D::setWeight(float weight) _weight = fabsf(weight); } +void Animate3D::setOriginInterval(float interval) +{ + _originInterval = interval; +} + Animate3D::Animate3D() : _state(Animate3D::Animate3DState::Running) , _animation(nullptr) @@ -258,6 +264,7 @@ Animate3D::Animate3D() , _playReverse(false) , _accTransTime(0.0f) , _lastTime(0.0f) +, _originInterval(0.0f) { } diff --git a/cocos/3d/CCAnimate3D.h b/cocos/3d/CCAnimate3D.h index 1b75e9d3c3..fc0df412cc 100644 --- a/cocos/3d/CCAnimate3D.h +++ b/cocos/3d/CCAnimate3D.h @@ -85,6 +85,10 @@ public: float getWeight() const { return _weight; } void setWeight(float weight); + /**get & set origin interval*/ + void setOriginInterval(float interval); + float getOriginInterval() const {return _originInterval; } + /** animate transition time */ static float getTransitionTime() { return _transTime; } @@ -117,6 +121,7 @@ protected: static float _transTime; //transition time from one animate3d to another float _accTransTime; // acculate transition time float _lastTime; // last t (0 - 1) + float _originInterval;// save origin interval time std::unordered_map _boneCurves; //weak ref //sprite animates