Skip to content
18 changes: 18 additions & 0 deletions flixel/util/FlxTimer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,24 @@ class FlxTimer implements IFlxDestroyable
}
}

/**
* Ends a loop early and calls onComplete(), regardless of how much time is left.
*/
public function complete():Void
{
if (active && !finished)
{
_timeCounter = 0;
_loopsCounter++;

onLoopFinished();
if (_loopsCounter == loops)
{
cancel();
}
}
}

@:allow(flixel.util.FlxTimerManager)
function onLoopFinished():Void
{
Expand Down
Loading