diff --git a/cocos/base/CCScheduler.cpp b/cocos/base/CCScheduler.cpp index 0acc1d3b93..7977dfff65 100644 --- a/cocos/base/CCScheduler.cpp +++ b/cocos/base/CCScheduler.cpp @@ -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; } }