@@ -390,11 +390,6 @@ 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
-
398
393
/**
399
394
* The displayed value of the player's health.
400
395
* Used to provide smooth animations based on linear interpolation of the player's health.
@@ -902,7 +897,8 @@ class PlayState extends MusicBeatSubState
902
897
if (isInCountdown )
903
898
{
904
899
// Do NOT apply offsets at this point, because they already got applied the previous frame!
905
- if (focus ) Conductor .instance .update (Conductor .instance .songPosition + elapsed * 1000 , false );
900
+ @:privateAccess
901
+ if (FlxG .game ._lostFocus && Preferences .autoPause ) Conductor .instance .update (Conductor .instance .songPosition + elapsed * 1000 , false );
906
902
if (Conductor .instance .songPosition >= (startTimestamp + Conductor .instance .combinedOffset ))
907
903
{
908
904
trace (" started song at " + Conductor .instance .songPosition );
@@ -921,9 +917,9 @@ class PlayState extends MusicBeatSubState
921
917
Conductor .instance .formatOffset = 0.0 ;
922
918
}
923
919
924
- if ( focus ) Conductor . instance . update (( FlxG . sound . music . pitch != 1 ) ? FlxG . sound . music . time + elapsed * 1000 : ( Conductor . instance . songPosition
925
- + elapsed * 1000 ),
926
- false ); // Normal conductor update.
920
+ @ :privateAccess
921
+ if ( FlxG . game . _lostFocus && Preferences . autoPause ) Conductor . instance . update (( FlxG . sound . music . pitch != 1 ) ? FlxG . sound . music . time + elapsed * 1000
922
+ : ( Conductor . instance . songPosition + elapsed * 1000 ), false ); // Normal conductor update.
927
923
928
924
// If, after updating the conductor, the instrumental has finished, end the song immediately.
929
925
// This helps prevent a major bug where the level suddenly loops back to the start or middle.
@@ -1342,8 +1338,6 @@ class PlayState extends MusicBeatSubState
1342
1338
*/
1343
1339
public override function onFocus (): Void
1344
1340
{
1345
- focus = true ;
1346
-
1347
1341
if (VideoCutscene .isPlaying () && FlxG .autoPause && isGamePaused ) VideoCutscene .pauseVideo ();
1348
1342
#if html5
1349
1343
else
@@ -1388,7 +1382,6 @@ class PlayState extends MusicBeatSubState
1388
1382
*/
1389
1383
public override function onFocusLost (): Void
1390
1384
{
1391
- focus = false ;
1392
1385
#if html5
1393
1386
if (FlxG .autoPause ) VideoCutscene .pauseVideo ();
1394
1387
#end
0 commit comments