diff --git a/haxe/Timer.hx b/haxe/Timer.hx index 73d1d0372..344eb7202 100644 --- a/haxe/Timer.hx +++ b/haxe/Timer.hx @@ -1,5 +1,5 @@ package haxe; -#if (macro || (!neko && !cpp && !nodejs)) +#if (macro || (!neko && !cpp)) // Original haxe.Timer class diff --git a/lime/_backend/native/NativeApplication.hx b/lime/_backend/native/NativeApplication.hx index 804d0f4b1..85747b405 100644 --- a/lime/_backend/native/NativeApplication.hx +++ b/lime/_backend/native/NativeApplication.hx @@ -13,6 +13,7 @@ import lime.system.System; import lime.ui.Gamepad; import lime.ui.Window; +@:access(haxe.Timer) @:access(lime.app.Application) @:access(lime.graphics.Renderer) @:access(lime.ui.Gamepad) @@ -261,8 +262,7 @@ class NativeApplication { private function handleUpdateEvent ():Void { - Timer.__checkTimers (); - + updateTimer (); parent.onUpdate.dispatch (updateEventInfo.deltaTime); } @@ -324,6 +324,46 @@ class NativeApplication { } + private function updateTimer ():Void { + + if (Timer.sRunningTimers.length > 0) { + + var currentTime = System.getTimer (); + var foundNull = false; + var timer; + + for (i in 0...Timer.sRunningTimers.length) { + + timer = Timer.sRunningTimers[i]; + + if (timer != null) { + + if (currentTime >= timer.mFireAt) { + + timer.mFireAt += timer.mTime; + timer.run (); + + } + + } else { + + foundNull = true; + + } + + } + + if (foundNull) { + + Timer.sRunningTimers = Timer.sRunningTimers.filter (function (val) { return val != null; }); + + } + + } + + } + + private function __cleanup ():Void { AudioManager.shutdown ();