mirror of https://github.com/axmolengine/axmol.git
Merge pull request #15348 from minggo/action_issue
some bugs fixed of Repeat
This commit is contained in:
commit
5f4e8a65c4
|
@ -409,10 +409,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;
|
||||
|
@ -455,7 +456,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);
|
||||
|
@ -467,8 +468,11 @@ void Repeat::update(float dt)
|
|||
}
|
||||
|
||||
// fix for issue #1288, incorrect end value of repeat
|
||||
if(dt >= 1.0f && _total < _times)
|
||||
if(fabs(dt - 1.0f) < FLT_EPSILON && _total < _times)
|
||||
{
|
||||
if (!(sendUpdateEventToScript(1.0f, _innerAction)))
|
||||
_innerAction->update(1.0f);
|
||||
|
||||
_total++;
|
||||
}
|
||||
|
||||
|
@ -477,8 +481,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
|
||||
|
|
Loading…
Reference in New Issue