Skip to content
Browse files

fixed some timer bugs

  • Loading branch information...
1 parent af2c3f7 commit 45adcc7ad11920e5ffd0e7cf8b81068a9f62d9e7 @AdamAtomic committed
Showing with 7 additions and 8 deletions.
  1. +6 −7 org/flixel/FlxTimer.as
  2. +1 −1 org/flixel/plugin/TimerManager.as
View
13 org/flixel/FlxTimer.as
@@ -68,6 +68,9 @@ package org.flixel
*/
public function destroy():void
{
+ var timerManager:TimerManager = manager;
+ if(timerManager != null)
+ timerManager.remove(this);
stop();
_callback = null;
}
@@ -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)
@@ -115,6 +115,8 @@ package org.flixel
return this;
}
+ paused = false;
+ finished = false;
time = Time;
loops = Loops;
_callback = Callback;
@@ -129,9 +131,6 @@ package org.flixel
public function stop():void
{
finished = true;
- var timerManager:TimerManager = manager;
- if(timerManager != null)
- timerManager.remove(this);
}
/**
View
2 org/flixel/plugin/TimerManager.as
@@ -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();
}
}

0 comments on commit 45adcc7

Please sign in to comment.
Something went wrong with that request. Please try again.