Fix issues with animation offsets breaking on restart on characters with high offstes.

This commit is contained in:
EliteMasterEric 2024-09-29 07:06:11 -04:00
parent e3ed153a7c
commit 90f6f80a71
3 changed files with 2 additions and 16 deletions
source/funkin/play

View file

@ -233,15 +233,9 @@ class BaseCharacter extends Bopper
*/ */
public function resetCharacter(resetCamera:Bool = true):Void public function resetCharacter(resetCamera:Bool = true):Void
{ {
// Reset the animation offsets. This will modify x and y to be the absolute position of the character. // Set the x and y to be their original values.
// this.animOffsets = [0, 0];
// Now we can set the x and y to be their original values without having to account for animOffsets.
this.resetPosition(); this.resetPosition();
// Then reapply animOffsets...
// applyAnimationOffsets(getCurrentAnimation());
this.dance(true); // Force to avoid the old animation playing with the wrong offset at the start of the song. this.dance(true); // Force to avoid the old animation playing with the wrong offset at the start of the song.
// Make sure we are playing the idle animation // Make sure we are playing the idle animation
// ...then update the hitbox so that this.width and this.height are correct. // ...then update the hitbox so that this.width and this.height are correct.

View file

@ -150,11 +150,8 @@ class Bopper extends StageProp implements IPlayStateScriptedClass
*/ */
public function resetPosition() public function resetPosition()
{ {
var oldAnimOffsets = [animOffsets[0], animOffsets[1]];
animOffsets = [0, 0];
this.x = originalPosition.x; this.x = originalPosition.x;
this.y = originalPosition.y; this.y = originalPosition.y;
animOffsets = oldAnimOffsets;
} }
function update_shouldAlternate():Void function update_shouldAlternate():Void

View file

@ -440,12 +440,7 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass implements
character.x = stageCharData.position[0] - character.characterOrigin.x; character.x = stageCharData.position[0] - character.characterOrigin.x;
character.y = stageCharData.position[1] - character.characterOrigin.y; character.y = stageCharData.position[1] - character.characterOrigin.y;
@:privateAccess(funkin.play.stage.Bopper) character.originalPosition.set(character.x, character.y);
{
// Undo animOffsets before saving original position.
character.originalPosition.x = character.x + character.animOffsets[0];
character.originalPosition.y = character.y + character.animOffsets[1];
}
var finalScale = character.getBaseScale() * stageCharData.scale; var finalScale = character.getBaseScale() * stageCharData.scale;
character.setScale(finalScale); // Don't use scale.set for characters! character.setScale(finalScale); // Don't use scale.set for characters!