Skip to content

Commit

Permalink
uncapped framerate on web
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjamuffin99 committed Jul 16, 2024
1 parent 7cd19a0 commit 35ba566
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 35ba566

Please sign in to comment.