Skip to content

Commit

Permalink
Merge pull request #1275 from Gama11/FlxTimerOnComplete
Browse files Browse the repository at this point in the history
FlxTimer#complete -> onComplete
  • Loading branch information
gamedevsam committed Aug 20, 2014
2 parents 54c1715 + 4a6b55b commit 6d2deeb
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions flixel/util/FlxTimer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FlxTimer implements IFlxDestroyable
* Function that gets called when timer completes.
* Callback should be formed "onTimer(Timer:FlxTimer);"
*/
public var complete:FlxTimer->Void;
public var onComplete:FlxTimer->Void;
/**
* Read-only: check how much time is left on the timer.
*/
Expand Down Expand Up @@ -71,14 +71,15 @@ class FlxTimer implements IFlxDestroyable
* Creates a new timer (and calls start() right away if Time != null).
*
* @param Time How many seconds it takes for the timer to go off.
* @param Callback Optional, triggered whenever the time runs out, once for each loop. Callback should be formed "onTimer(Timer:FlxTimer);"
* @param OnComplete Optional, triggered whenever the time runs out, once for each loop.
* Callback should be formed "onTimer(Timer:FlxTimer);"
* @param Loops How many times the timer should go off. 0 means "looping forever".
*/
public function new(?Time:Null<Float>, ?Callback:FlxTimer->Void, Loops:Int = 1)
public function new(?Time:Null<Float>, ?OnComplete:FlxTimer->Void, Loops:Int = 1)
{
if (Time != null)
{
start(Time, Callback, Loops);
start(Time, OnComplete, Loops);
}
}

Expand All @@ -87,18 +88,19 @@ class FlxTimer implements IFlxDestroyable
*/
public function destroy():Void
{
complete = null;
onComplete = null;
}

/**
* Starts the timer and adds the timer to the timer manager.
*
* @param Time How many seconds it takes for the timer to go off.
* @param Callback Optional, triggered whenever the time runs out, once for each loop. Callback should be formed "onTimer(Timer:FlxTimer);"
* @param OnComplete Optional, triggered whenever the time runs out, once for each loop.
* Callback should be formed "onTimer(Timer:FlxTimer);"
* @param Loops How many times the timer should go off. 0 means "looping forever".
* @return A reference to itself (handy for chaining or whatever).
*/
public function start(Time:Float = 1, ?Callback:FlxTimer->Void, Loops:Int = 1):FlxTimer
public function start(Time:Float = 1, ?OnComplete:FlxTimer->Void, Loops:Int = 1):FlxTimer
{
if (manager != null && !_inManager)
{
Expand All @@ -116,7 +118,7 @@ class FlxTimer implements IFlxDestroyable
}

loops = Loops;
complete = Callback;
onComplete = OnComplete;
_timeCounter = 0;
_loopsCounter = 0;
return this;
Expand All @@ -132,7 +134,7 @@ class FlxTimer implements IFlxDestroyable
{
NewTime = time;
}
start(NewTime, complete, loops);
start(NewTime, onComplete, loops);
return this;
}

Expand Down Expand Up @@ -166,9 +168,9 @@ class FlxTimer implements IFlxDestroyable
_timeCounter -= time;
_loopsCounter++;

if (complete != null)
if (onComplete != null)
{
complete(this);
onComplete(this);
}

if (loops > 0 && (_loopsCounter >= loops))
Expand Down

0 comments on commit 6d2deeb

Please sign in to comment.