From 66ca1c676da9852ba34f0b40630fedab3ba59b01 Mon Sep 17 00:00:00 2001 From: GINOFM Date: Mon, 19 Feb 2024 16:54:04 -0300 Subject: [PATCH 1/2] fix fps issues in mobile a solution for the fps issues in mobile --- scripts/_GameMaker.js | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index e57baca6..0edbef93 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -2291,34 +2291,23 @@ function GameMaker_Tick() newfps = 0; lastfpstime = g_CurrentTime; } - newfps++; // schedule next frame: // this might be best done after if(!Run_Paused) block, // but then an exception would halt the game loop. var nextFrameAt = g_FrameStartTime + 1000 / TargetSpeed; - var now = Date.now(); - var delay = g_FrameStartTime + 1000 / TargetSpeed - now; - if (delay < 0) delay = 0; - g_FrameStartTime = now + delay; - if (delay > 4) { - // 4ms is the general minimum timeout time as per spec, - // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers - setTimeout(function() { - if (window.yyRequestAnimationFrame) { - window.yyRequestAnimationFrame(animate); - } else { - // Don't re-enter, that would be bad. - //animate(); - } - }, delay); - } else { + var now = g_CurrentTime; + var delay = nextFrameAt - now; + if (delay < 0) { + delay = 0; + } + g_FrameStartTime +=delay; + if (delay <= 4) { if (window.yyRequestAnimationFrame) { window.yyRequestAnimationFrame(animate); - } else { - window.postMessage("yyRequestAnimationFrame", "*"); - } - } + } + } + newfps++; if (!Run_Paused) { From 5fa1d6fa278b703abda3629503bc09609548445b Mon Sep 17 00:00:00 2001 From: GINOFM Date: Tue, 20 Feb 2024 06:14:34 -0300 Subject: [PATCH 2/2] Update _GameMaker.js --- scripts/_GameMaker.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js index 0edbef93..6283c2e1 100644 --- a/scripts/_GameMaker.js +++ b/scripts/_GameMaker.js @@ -2291,7 +2291,7 @@ function GameMaker_Tick() newfps = 0; lastfpstime = g_CurrentTime; } - + newfps++; // schedule next frame: // this might be best done after if(!Run_Paused) block, // but then an exception would halt the game loop. @@ -2301,13 +2301,19 @@ function GameMaker_Tick() if (delay < 0) { delay = 0; } - g_FrameStartTime +=delay; + if (delay <= 4) { + g_FrameStartTime +=delay; if (window.yyRequestAnimationFrame) { window.yyRequestAnimationFrame(animate); - } - } - newfps++; + } else{ + + } + } else{ + g_FrameStartTime -=delay; + window.postMessage("yyRequestAnimationFrame", "*"); + } + if (!Run_Paused) {