mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-12-02 04:17:07 -05:00
Fix several crashes when reaching a game over in minimal mode
This commit is contained in:
parent
4c35b1d74f
commit
566a271a63
1 changed files with 78 additions and 51 deletions
|
@ -97,14 +97,14 @@ class GameOverSubState extends MusicBeatSubState
|
||||||
/**
|
/**
|
||||||
* Reset the game over configuration to the default.
|
* Reset the game over configuration to the default.
|
||||||
*/
|
*/
|
||||||
public static function reset()
|
public static function reset():Void
|
||||||
{
|
{
|
||||||
animationSuffix = "";
|
animationSuffix = '';
|
||||||
musicSuffix = "";
|
musicSuffix = '';
|
||||||
blueBallSuffix = "";
|
blueBallSuffix = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function create()
|
override public function create():Void
|
||||||
{
|
{
|
||||||
if (instance != null)
|
if (instance != null)
|
||||||
{
|
{
|
||||||
|
@ -130,23 +130,27 @@ class GameOverSubState extends MusicBeatSubState
|
||||||
|
|
||||||
// Pluck Boyfriend from the PlayState and place him (in the same position) in the GameOverSubState.
|
// Pluck Boyfriend from the PlayState and place him (in the same position) in the GameOverSubState.
|
||||||
// We can then play the character's `firstDeath` animation.
|
// We can then play the character's `firstDeath` animation.
|
||||||
boyfriend = PlayState.instance.currentStage.getBoyfriend(true);
|
if (PlayState.instance.isMinimalMode) {}
|
||||||
boyfriend.isDead = true;
|
else
|
||||||
add(boyfriend);
|
{
|
||||||
boyfriend.resetCharacter();
|
boyfriend = PlayState.instance.currentStage.getBoyfriend(true);
|
||||||
|
boyfriend.isDead = true;
|
||||||
|
add(boyfriend);
|
||||||
|
boyfriend.resetCharacter();
|
||||||
|
|
||||||
// Assign a camera follow point to the boyfriend's position.
|
// Assign a camera follow point to the boyfriend's position.
|
||||||
cameraFollowPoint = new FlxObject(PlayState.instance.cameraFollowPoint.x, PlayState.instance.cameraFollowPoint.y, 1, 1);
|
cameraFollowPoint = new FlxObject(PlayState.instance.cameraFollowPoint.x, PlayState.instance.cameraFollowPoint.y, 1, 1);
|
||||||
cameraFollowPoint.x = boyfriend.getGraphicMidpoint().x;
|
cameraFollowPoint.x = boyfriend.getGraphicMidpoint().x;
|
||||||
cameraFollowPoint.y = boyfriend.getGraphicMidpoint().y;
|
cameraFollowPoint.y = boyfriend.getGraphicMidpoint().y;
|
||||||
var offsets:Array<Float> = boyfriend.getDeathCameraOffsets();
|
var offsets:Array<Float> = boyfriend.getDeathCameraOffsets();
|
||||||
cameraFollowPoint.x += offsets[0];
|
cameraFollowPoint.x += offsets[0];
|
||||||
cameraFollowPoint.y += offsets[1];
|
cameraFollowPoint.y += offsets[1];
|
||||||
add(cameraFollowPoint);
|
add(cameraFollowPoint);
|
||||||
|
|
||||||
FlxG.camera.target = null;
|
FlxG.camera.target = null;
|
||||||
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.01);
|
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.01);
|
||||||
targetCameraZoom = PlayState?.instance?.currentStage?.camZoom * boyfriend.getDeathCameraZoom();
|
targetCameraZoom = PlayState?.instance?.currentStage?.camZoom * boyfriend.getDeathCameraZoom();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set up the audio
|
// Set up the audio
|
||||||
|
@ -164,21 +168,29 @@ class GameOverSubState extends MusicBeatSubState
|
||||||
|
|
||||||
var hasStartedAnimation:Bool = false;
|
var hasStartedAnimation:Bool = false;
|
||||||
|
|
||||||
override function update(elapsed:Float)
|
override function update(elapsed:Float):Void
|
||||||
{
|
{
|
||||||
if (!hasStartedAnimation)
|
if (!hasStartedAnimation)
|
||||||
{
|
{
|
||||||
hasStartedAnimation = true;
|
hasStartedAnimation = true;
|
||||||
|
|
||||||
if (boyfriend.hasAnimation('fakeoutDeath') && FlxG.random.bool((1 / 4096) * 100))
|
if (PlayState.instance.isMinimalMode)
|
||||||
{
|
{
|
||||||
boyfriend.playAnimation('fakeoutDeath', true, false);
|
// Play the "blue balled" sound. May play a variant if one has been assigned.
|
||||||
|
playBlueBalledSFX();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boyfriend.playAnimation('firstDeath', true, false); // ignoreOther is set to FALSE since you WANT to be able to mash and confirm game over!
|
if (boyfriend.hasAnimation('fakeoutDeath') && FlxG.random.bool((1 / 4096) * 100))
|
||||||
// Play the "blue balled" sound. May play a variant if one has been assigned.
|
{
|
||||||
playBlueBalledSFX();
|
boyfriend.playAnimation('fakeoutDeath', true, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boyfriend.playAnimation('firstDeath', true, false); // ignoreOther is set to FALSE since you WANT to be able to mash and confirm game over!
|
||||||
|
// Play the "blue balled" sound. May play a variant if one has been assigned.
|
||||||
|
playBlueBalledSFX();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,27 +253,34 @@ class GameOverSubState extends MusicBeatSubState
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Music hasn't started yet.
|
if (PlayState.instance.isMinimalMode)
|
||||||
switch (PlayStatePlaylist.campaignId)
|
|
||||||
{
|
{
|
||||||
// TODO: Make the behavior for playing Jeff's voicelines generic or un-hardcoded.
|
// startDeathMusic(1.0, false);
|
||||||
// This will simplify the class and make it easier for mods to add death quotes.
|
}
|
||||||
case "week7":
|
else
|
||||||
if (boyfriend.getCurrentAnimation().startsWith('firstDeath') && boyfriend.isAnimationFinished() && !playingJeffQuote)
|
{
|
||||||
{
|
// Music hasn't started yet.
|
||||||
playingJeffQuote = true;
|
switch (PlayStatePlaylist.campaignId)
|
||||||
playJeffQuote();
|
{
|
||||||
// Start music at lower volume
|
// TODO: Make the behavior for playing Jeff's voicelines generic or un-hardcoded.
|
||||||
startDeathMusic(0.2, false);
|
// This will simplify the class and make it easier for mods to add death quotes.
|
||||||
boyfriend.playAnimation('deathLoop' + animationSuffix);
|
case 'week7':
|
||||||
}
|
if (boyfriend.getCurrentAnimation().startsWith('firstDeath') && boyfriend.isAnimationFinished() && !playingJeffQuote)
|
||||||
default:
|
{
|
||||||
// Start music at normal volume once the initial death animation finishes.
|
playingJeffQuote = true;
|
||||||
if (boyfriend.getCurrentAnimation().startsWith('firstDeath') && boyfriend.isAnimationFinished())
|
playJeffQuote();
|
||||||
{
|
// Start music at lower volume
|
||||||
startDeathMusic(1.0, false);
|
startDeathMusic(0.2, false);
|
||||||
boyfriend.playAnimation('deathLoop' + animationSuffix);
|
boyfriend.playAnimation('deathLoop' + animationSuffix);
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
// Start music at normal volume once the initial death animation finishes.
|
||||||
|
if (boyfriend.getCurrentAnimation().startsWith('firstDeath') && boyfriend.isAnimationFinished())
|
||||||
|
{
|
||||||
|
startDeathMusic(1.0, false);
|
||||||
|
boyfriend.playAnimation('deathLoop' + animationSuffix);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +298,11 @@ class GameOverSubState extends MusicBeatSubState
|
||||||
isEnding = true;
|
isEnding = true;
|
||||||
startDeathMusic(1.0, true); // isEnding changes this function's behavior.
|
startDeathMusic(1.0, true); // isEnding changes this function's behavior.
|
||||||
|
|
||||||
boyfriend.playAnimation('deathConfirm' + animationSuffix, true);
|
if (PlayState.instance.isMinimalMode) {}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boyfriend.playAnimation('deathConfirm' + animationSuffix, true);
|
||||||
|
}
|
||||||
|
|
||||||
// After the animation finishes...
|
// After the animation finishes...
|
||||||
new FlxTimer().start(0.7, function(tmr:FlxTimer) {
|
new FlxTimer().start(0.7, function(tmr:FlxTimer) {
|
||||||
|
@ -289,10 +312,14 @@ class GameOverSubState extends MusicBeatSubState
|
||||||
FlxG.camera.fade(FlxColor.BLACK, 1, true, null, true);
|
FlxG.camera.fade(FlxColor.BLACK, 1, true, null, true);
|
||||||
PlayState.instance.needsReset = true;
|
PlayState.instance.needsReset = true;
|
||||||
|
|
||||||
// Readd Boyfriend to the stage.
|
if (PlayState.instance.isMinimalMode) {}
|
||||||
boyfriend.isDead = false;
|
else
|
||||||
remove(boyfriend);
|
{
|
||||||
PlayState.instance.currentStage.addCharacter(boyfriend, BF);
|
// Readd Boyfriend to the stage.
|
||||||
|
boyfriend.isDead = false;
|
||||||
|
remove(boyfriend);
|
||||||
|
PlayState.instance.currentStage.addCharacter(boyfriend, BF);
|
||||||
|
}
|
||||||
|
|
||||||
// Snap reset the camera which may have changed because of the player character data.
|
// Snap reset the camera which may have changed because of the player character data.
|
||||||
resetCameraZoom();
|
resetCameraZoom();
|
||||||
|
|
Loading…
Reference in a new issue