From c2bdb1b75cb137f86d5e1d123303b5533f3800f0 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Mon, 19 Jan 2026 00:48:59 +0100 Subject: [PATCH] frameOffset for atlases (need testing) --- source/funkin/backend/FunkinSprite.hx | 24 +++++++++++++++++++ .../editors/character/CharacterAnimButton.hx | 14 ++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/source/funkin/backend/FunkinSprite.hx b/source/funkin/backend/FunkinSprite.hx index 78126bab..1ddfe442 100644 --- a/source/funkin/backend/FunkinSprite.hx +++ b/source/funkin/backend/FunkinSprite.hx @@ -376,6 +376,30 @@ class FunkinSprite extends FlxAnimate implements IBeatReceiver implements IOffse return val; } + override function draw():Void { + if (isAnimate) { + var posOffset:FlxPoint = FlxPoint.get(-frameOffset.x * scale.x, -frameOffset.y * scale.y); + + var angleOff = angle; + if (frameOffsetAngle != null) + angleOff = frameOffsetAngle; + angleOff *= FlxAngle.TO_RAD; + + posOffset.rotateWithTrig(Math.sin(angleOff), Math.cos(angleOff)); + + x += posOffset.x; + y += posOffset.y; + + super.draw(); + + x -= posOffset.x; + y -= posOffset.y; + + posOffset.put(); + } else + super.draw(); + } + override function drawComplex(camera:FlxCamera):Void { #if (flixel < "6.1.0") final frame = this._frame; #end diff --git a/source/funkin/editors/character/CharacterAnimButton.hx b/source/funkin/editors/character/CharacterAnimButton.hx index 5bc20a27..6ced6f36 100644 --- a/source/funkin/editors/character/CharacterAnimButton.hx +++ b/source/funkin/editors/character/CharacterAnimButton.hx @@ -264,7 +264,19 @@ class CharacterAnimButton extends UIButton { var oldAnim:String = animData.anim; animData.anim = newAnim; - __refreshAnimation(); + var flxAnimation:FlxAnimation = __getFlxAnimation(); + flxAnimation.prefix = newAnim; + + refreshFlxAnimationFrames(flxAnimation, animData); + + if (valid) { + parent.buildAnimDisplay(anim, data); + animationDisplayBG.alpha = 1; + } else { + parent.removeAnimDisplay(anim); + animationDisplayBG.alpha = 0.4; + } + if (parent.character.getAnimName() == anim) CharacterEditor.instance.playAnimation(anim);