Skip to content

Commit 459dacb

Browse files
committed
Conductor fixed
1 parent edb270d commit 459dacb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

source/funkin/play/PlayState.hx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ class PlayState extends MusicBeatSubState
390390
*/
391391
var mayPauseGame:Bool = true;
392392

393+
/**
394+
* True when the window is focused, false when not.
395+
*/
396+
var focus:Bool = true;
397+
393398
/**
394399
* The displayed value of the player's health.
395400
* Used to provide smooth animations based on linear interpolation of the player's health.
@@ -897,7 +902,7 @@ class PlayState extends MusicBeatSubState
897902
if (isInCountdown)
898903
{
899904
// 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);
901906
if (Conductor.instance.songPosition >= (startTimestamp + Conductor.instance.combinedOffset))
902907
{
903908
trace("started song at " + Conductor.instance.songPosition);
@@ -916,7 +921,7 @@ class PlayState extends MusicBeatSubState
916921
Conductor.instance.formatOffset = 0.0;
917922
}
918923

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.
920925
}
921926

922927
var androidPause:Bool = false;
@@ -1328,6 +1333,8 @@ class PlayState extends MusicBeatSubState
13281333
*/
13291334
public override function onFocus():Void
13301335
{
1336+
focus = true;
1337+
13311338
if (VideoCutscene.isPlaying() && FlxG.autoPause && isGamePaused) VideoCutscene.pauseVideo();
13321339
#if html5
13331340
else
@@ -1372,6 +1379,7 @@ class PlayState extends MusicBeatSubState
13721379
*/
13731380
public override function onFocusLost():Void
13741381
{
1382+
focus = false;
13751383
#if html5
13761384
if (FlxG.autoPause) VideoCutscene.pauseVideo();
13771385
#end

0 commit comments

Comments
 (0)