[Node::scheduleOnce]Fixed the callback will be executed multiple times if the value of delay equal zero.

This commit is contained in:
WenhaiLin 2015-08-26 23:41:48 +08:00
parent ee5c541cd1
commit 393af19237
1 changed files with 4 additions and 8 deletions

View File

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