From 87b5397c43383acd0643dae595fa1bebb74cbae3 Mon Sep 17 00:00:00 2001 From: Wenhai Lin Date: Fri, 8 Apr 2016 21:02:00 +0800 Subject: [PATCH] Bugs fixed of 'Repeat'. --- native/cocos/2d/CCActionInterval.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/native/cocos/2d/CCActionInterval.cpp b/native/cocos/2d/CCActionInterval.cpp index 7bd6174487..f9b2871d83 100644 --- a/native/cocos/2d/CCActionInterval.cpp +++ b/native/cocos/2d/CCActionInterval.cpp @@ -450,10 +450,11 @@ bool Repeat::initWithAction(FiniteTimeAction *action, unsigned int times) _actionInstant = dynamic_cast(action) ? true : false; //an instant action needs to be executed one time less in the update method since it uses startWithTarget to execute the action - if (_actionInstant) - { - _times -=1; - } + // minggo: instant action doesn't execute action in Repeat::startWithTarget(), so comment it. +// if (_actionInstant) +// { +// _times -=1; +// } _total = 0; return true; @@ -494,7 +495,7 @@ void Repeat::update(float dt) { if (dt >= _nextDt) { - while (dt > _nextDt && _total < _times) + while (dt >= _nextDt && _total < _times) { if (!(sendUpdateEventToScript(1.0f, _innerAction))) _innerAction->update(1.0f); @@ -506,8 +507,11 @@ void Repeat::update(float dt) } // fix for issue #1288, incorrect end value of repeat - if(dt >= 1.0f && _total < _times) + if(dt + FLT_EPSILON > 1.0f && _total < _times) { + if (!(sendUpdateEventToScript(1.0f, _innerAction))) + _innerAction->update(1.0f); + _total++; } @@ -516,8 +520,9 @@ void Repeat::update(float dt) { if (_total == _times) { - if (!(sendUpdateEventToScript(1, _innerAction))) - _innerAction->update(1); + // minggo: inner action update is invoked above, don't have to invoke it here +// if (!(sendUpdateEventToScript(1, _innerAction))) +// _innerAction->update(1); _innerAction->stop(); } else