Skip to content

Commit

Permalink
fixed some timer bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamAtomic committed Apr 30, 2011
1 parent af2c3f7 commit 45adcc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions org/flixel/FlxTimer.as
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ package org.flixel
*/
public function destroy():void
{
var timerManager:TimerManager = manager;
if(timerManager != null)
timerManager.remove(this);
stop();
_callback = null;
}
Expand All @@ -80,16 +83,13 @@ package org.flixel
*/
public function update():void
{
if(paused || finished)
return;

_timeCounter += FlxG.elapsed;
while((_timeCounter >= time) && !paused && !finished)
{
_timeCounter -= time;

_loopsCounter++;
if(_loopsCounter >= loops)
if((loops > 0) && (_loopsCounter >= loops))
stop();

if(_callback != null)
Expand All @@ -115,6 +115,8 @@ package org.flixel
return this;
}

paused = false;
finished = false;
time = Time;
loops = Loops;
_callback = Callback;
Expand All @@ -129,9 +131,6 @@ package org.flixel
public function stop():void
{
finished = true;
var timerManager:TimerManager = manager;
if(timerManager != null)
timerManager.remove(this);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion org/flixel/plugin/TimerManager.as
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ package org.flixel.plugin
while(i >= 0)
{
timer = _timers[i--] as FlxTimer;
if((timer != null) && !timer.paused && !timer.finished)
if((timer != null) && !timer.paused && !timer.finished && (timer.time > 0))
timer.update();
}
}
Expand Down

0 comments on commit 45adcc7

Please sign in to comment.