@@ -390,6 +390,11 @@ class PlayState extends MusicBeatSubState
390
390
*/
391
391
var mayPauseGame : Bool = true ;
392
392
393
+ /**
394
+ * True when the window is focused, false when not.
395
+ */
396
+ var focus : Bool = true ;
397
+
393
398
/**
394
399
* The displayed value of the player's health.
395
400
* Used to provide smooth animations based on linear interpolation of the player's health.
@@ -897,7 +902,7 @@ class PlayState extends MusicBeatSubState
897
902
if (isInCountdown )
898
903
{
899
904
// Do NOT apply offsets at this point, because they already got applied the previous frame!
900
- Conductor .instance .update (Conductor .instance .songPosition + elapsed * 1000 , false );
905
+ if ( focus && ! isGamePaused ) Conductor .instance .update (Conductor .instance .songPosition + elapsed * 1000 , false );
901
906
if (Conductor .instance .songPosition >= (startTimestamp + Conductor .instance .combinedOffset ))
902
907
{
903
908
trace (" started song at " + Conductor .instance .songPosition );
@@ -916,7 +921,7 @@ class PlayState extends MusicBeatSubState
916
921
Conductor .instance .formatOffset = 0.0 ;
917
922
}
918
923
919
- Conductor .instance .update (Conductor . instance . songPosition + elapsed * 1000 , false ); // Normal conductor update.
924
+ if ( focus && ! isGamePaused ) Conductor .instance .update (FlxG . sound . music . time + elapsed * 1000 , false ); // Normal conductor update.
920
925
}
921
926
922
927
var androidPause : Bool = false ;
@@ -1328,6 +1333,8 @@ class PlayState extends MusicBeatSubState
1328
1333
*/
1329
1334
public override function onFocus (): Void
1330
1335
{
1336
+ focus = true ;
1337
+
1331
1338
if (VideoCutscene .isPlaying () && FlxG .autoPause && isGamePaused ) VideoCutscene .pauseVideo ();
1332
1339
#if html5
1333
1340
else
@@ -1372,6 +1379,7 @@ class PlayState extends MusicBeatSubState
1372
1379
*/
1373
1380
public override function onFocusLost (): Void
1374
1381
{
1382
+ focus = false ;
1375
1383
#if html5
1376
1384
if (FlxG .autoPause ) VideoCutscene .pauseVideo ();
1377
1385
#end
0 commit comments