Simplify Timer.stop() (#1839)
This commit is contained in:
@@ -270,19 +270,7 @@ class Timer
|
||||
|
||||
public function stop():Void
|
||||
{
|
||||
if (mRunning)
|
||||
{
|
||||
mRunning = false;
|
||||
|
||||
for (i in 0...sRunningTimers.length)
|
||||
{
|
||||
if (sRunningTimers[i] == this)
|
||||
{
|
||||
sRunningTimers[i] = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
mRunning = false;
|
||||
}
|
||||
|
||||
@:noCompletion private function __check(inTime:Float)
|
||||
|
||||
@@ -94,9 +94,9 @@ class NativeApplication
|
||||
if (pauseTimer > -1)
|
||||
{
|
||||
var offset = System.getTimer() - pauseTimer;
|
||||
for (i in 0...Timer.sRunningTimers.length)
|
||||
for (timer in Timer.sRunningTimers)
|
||||
{
|
||||
if (Timer.sRunningTimers[i] != null) Timer.sRunningTimers[i].mFireAt += offset;
|
||||
if (timer.mRunning) timer.mFireAt += offset;
|
||||
}
|
||||
pauseTimer = -1;
|
||||
}
|
||||
@@ -578,16 +578,13 @@ class NativeApplication
|
||||
if (Timer.sRunningTimers.length > 0)
|
||||
{
|
||||
var currentTime = System.getTimer();
|
||||
var foundNull = false;
|
||||
var timer;
|
||||
var foundStopped = false;
|
||||
|
||||
for (i in 0...Timer.sRunningTimers.length)
|
||||
for (timer in Timer.sRunningTimers)
|
||||
{
|
||||
timer = Timer.sRunningTimers[i];
|
||||
|
||||
if (timer != null)
|
||||
if (timer.mRunning)
|
||||
{
|
||||
if (timer.mRunning && currentTime >= timer.mFireAt)
|
||||
if (currentTime >= timer.mFireAt)
|
||||
{
|
||||
timer.mFireAt += timer.mTime;
|
||||
timer.run();
|
||||
@@ -595,15 +592,15 @@ class NativeApplication
|
||||
}
|
||||
else
|
||||
{
|
||||
foundNull = true;
|
||||
foundStopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundNull)
|
||||
if (foundStopped)
|
||||
{
|
||||
Timer.sRunningTimers = Timer.sRunningTimers.filter(function(val)
|
||||
{
|
||||
return val != null;
|
||||
return val.mRunning;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user