@@ -2272,34 +2272,7 @@ function GameMaker_Tick()
2272
2272
newfps = 0 ;
2273
2273
lastfpstime = g_CurrentTime ;
2274
2274
}
2275
- newfps ++ ;
2276
2275
2277
- // schedule next frame:
2278
- // this might be best done after if(!Run_Paused) block,
2279
- // but then an exception would halt the game loop.
2280
- var nextFrameAt = g_FrameStartTime + 1000 / TargetSpeed ;
2281
- var now = Date . now ( ) ;
2282
- var delay = g_FrameStartTime + 1000 / TargetSpeed - now ;
2283
- if ( delay < 0 ) delay = 0 ;
2284
- g_FrameStartTime = now + delay ;
2285
- if ( delay > 4 ) {
2286
- // 4ms is the general minimum timeout time as per spec,
2287
- // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
2288
- setTimeout ( function ( ) {
2289
- if ( window . yyRequestAnimationFrame ) {
2290
- window . yyRequestAnimationFrame ( animate ) ;
2291
- } else {
2292
- // Don't re-enter, that would be bad.
2293
- //animate();
2294
- }
2295
- } , delay ) ;
2296
- } else {
2297
- if ( window . yyRequestAnimationFrame ) {
2298
- window . yyRequestAnimationFrame ( animate ) ;
2299
- } else {
2300
- window . postMessage ( "yyRequestAnimationFrame" , "*" ) ;
2301
- }
2302
- }
2303
2276
2304
2277
if ( ! Run_Paused )
2305
2278
{
@@ -2370,6 +2343,26 @@ function GameMaker_Tick()
2370
2343
g_MouseDeltaY = 0 ;
2371
2344
}
2372
2345
2346
+
2347
+ // schedule next frame:
2348
+ // this might be best done after if(!Run_Paused) block,
2349
+ // but then an exception would halt the game loop.
2350
+ var nextFrameAt = g_FrameStartTime + 1000 / TargetSpeed ;
2351
+ var now = g_CurrentTime ;
2352
+ var delay = nextFrameAt - now ;
2353
+ if ( delay < 0 ) delay = 0 ;
2354
+
2355
+ g_FrameStartTime += delay ;
2356
+
2357
+ if ( delay <= 4 ) {
2358
+ if ( window . yyRequestAnimationFrame ) {
2359
+ window . yyRequestAnimationFrame ( animate ) ;
2360
+ } else {
2361
+ window . postMessage ( "yyRequestAnimationFrame" , "*" ) ;
2362
+ }
2363
+ }
2364
+ newfps ++ ;
2365
+
2373
2366
// if in DEBUG mode, do debug "stuff"
2374
2367
// @if feature("debug")
2375
2368
if ( g_pGMFile . Options && g_pGMFile . Options . debugMode ) {
0 commit comments