Merge pull request #13585 from WenhaiLin/v3.8-scheduleOnce-hotfix

[Node::scheduleOnce]Fixed the callback will be executed multiple times if the value of delay parameter equal zero.
This commit is contained in:
子龙山人 2015-08-27 10:54:04 +08:00
commit 30d6c82da6
1 changed files with 4 additions and 8 deletions

View File

@ -130,19 +130,15 @@ void Timer::update(float dt)
trigger(interval);
_elapsed -= interval;
_timesExecuted += 1;
if (_elapsed <= 0.f)
if (!_runForever && _timesExecuted > _repeat)
{
cancel();
break;
}
if (_runForever)
if (_elapsed <= 0.f)
{
continue;
}
if (_timesExecuted > _repeat)
{ //unschedule timer
cancel();
break;
}
}