Bugs fixed of 'Repeat'.

This commit is contained in:
Wenhai Lin
2016-04-08 21:02:00 +08:00
parent e42840bfac
commit 87b5397c43
+13 -8
View File
@@ -450,10 +450,11 @@ bool Repeat::initWithAction(FiniteTimeAction *action, unsigned int times)
_actionInstant = dynamic_cast<ActionInstant*>(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