1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-20 13:53:13 +00:00

Fix issue with incorrect music after pausing during countdown

Whenever you pause gameplay, the `PlayState` pauses the music.
But if you start a song from the main menu, pause during the 3,2,1
countdown, and then unpause, the main menu music will incorrectly
start playing again due to `FlxG.sound.music` still referencing it
before the gameplay song starts playing.

Only restart the music if it was actually playing to begin with by
storing the play state in `PlayState.openSubState` when we pause.

This hopefully avoids any other cases where the pause state gets
pushed while the music is stopped.
This commit is contained in:
Mike Welsh 2024-02-16 04:54:27 -08:00
parent 15accdf10f
commit e90c37ad75

View file

@ -354,6 +354,11 @@ class PlayState extends MusicBeatSubState
*/
var startingSong:Bool = false;
/**
* False if `FlxG.sound.music`
*/
var musicPausedBySubState:Bool = false;
/**
* False until `create()` has completed.
*/
@ -1042,6 +1047,7 @@ class PlayState extends MusicBeatSubState
// Pause the music.
if (FlxG.sound.music != null)
{
musicPausedBySubState = FlxG.sound.music.playing;
FlxG.sound.music.pause();
if (vocals != null) vocals.pause();
}
@ -1049,7 +1055,6 @@ class PlayState extends MusicBeatSubState
// Pause the countdown.
Countdown.pauseCountdown();
}
else {}
super.openSubState(subState);
}
@ -1069,7 +1074,10 @@ class PlayState extends MusicBeatSubState
if (event.eventCanceled) return;
// Resume
FlxG.sound.music.play(FlxG.sound.music.time);
if (musicPausedBySubState)
{
FlxG.sound.music.play(FlxG.sound.music.time);
}
if (FlxG.sound.music != null && !startingSong && !isInCutscene) resyncVocals();