1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-02-03 18:28:41 +00:00

gameover positioning fixes

This commit is contained in:
Cameron Taylor 2024-09-09 12:34:55 -04:00
parent d9a3604880
commit 591d4a29f4

View file

@ -17,6 +17,7 @@ import funkin.ui.story.StoryMenuState;
import funkin.util.MathUtil;
import openfl.utils.Assets;
import funkin.effects.RetroCameraFade;
import flixel.math.FlxPoint;
/**
* A substate which renders over the PlayState when the player dies.
@ -168,8 +169,8 @@ class GameOverSubState extends MusicBeatSubState
// Assign a camera follow point to the boyfriend's position.
cameraFollowPoint = new FlxObject(PlayState.instance.cameraFollowPoint.x, PlayState.instance.cameraFollowPoint.y, 1, 1);
cameraFollowPoint.x = boyfriend.getGraphicMidpoint().x;
cameraFollowPoint.y = boyfriend.getGraphicMidpoint().y;
cameraFollowPoint.x = getMidPointOld(boyfriend).x;
cameraFollowPoint.y = getMidPointOld(boyfriend).y;
var offsets:Array<Float> = boyfriend.getDeathCameraOffsets();
cameraFollowPoint.x += offsets[0];
cameraFollowPoint.y += offsets[1];
@ -180,6 +181,21 @@ class GameOverSubState extends MusicBeatSubState
targetCameraZoom = (PlayState?.instance?.currentStage?.camZoom ?? 1.0) * boyfriend.getDeathCameraZoom();
}
/**
* FlxSprite.getMidpoint(); calculations changed in this git commit
* https://github.com/HaxeFlixel/flixel/commit/1553b5af0871462fcefedc091b7885437d6c36d2
* https://github.com/HaxeFlixel/flixel/pull/3125
*
* So we use this to do the old math that gets the midpoint of our graphics
* Luckily, we don't use getGraphicMidpoint() much in the code, so it's fine being in GameoverSubState here.
* @return FlxPoint
*/
function getMidPointOld(spr:FlxSprite, ?point:FlxPoint):FlxPoint
{
if (point == null) point = FlxPoint.get();
return point.set(spr.x + spr.frameWidth * 0.5 * spr.scale.x, spr.y + spr.frameHeight * 0.5 * spr.scale.y);
}
/**
* Forcibly reset the camera zoom level to that of the current stage.
* This prevents camera zoom events from adversely affecting the game over state.