From 35ba5663a1ff9b9d95bf2c10e843156c17be4801 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 15 Jul 2024 23:10:08 -0400 Subject: [PATCH] uncapped framerate on web --- source/Main.hx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/Main.hx b/source/Main.hx index add5bbc67..0e5ed0c31 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -66,6 +66,18 @@ class Main extends Sprite function init(?event:Event):Void { + #if web + untyped js.Syntax.code(" + window.requestAnimationFrame = function(callback, element) { + var currTime = new Date().getTime(); + var timeToCall = 0; + var id = window.setTimeout(function() { callback(currTime + timeToCall); }, + timeToCall); + lastTime = currTime + timeToCall; + return id; + }"); + #end + if (hasEventListener(Event.ADDED_TO_STAGE)) { removeEventListener(Event.ADDED_TO_STAGE, init);