From e3e82e82498745f2b095a2b67c387c91a2c5d6b7 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Wed, 21 Jan 2026 20:37:13 +0100 Subject: [PATCH] fixed animation swapping on atlas characters --- source/funkin/backend/utils/CoolUtil.hx | 24 ++++++++++++++++++++++++ source/funkin/game/Character.hx | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index 65dc4340..60f92511 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -34,6 +34,7 @@ import lime.utils.Assets; import openfl.display.BitmapData; import openfl.geom.ColorTransform; import animate.FlxAnimateJson; +import flixel.animation.FlxAnimationController; using StringTools; @@ -574,6 +575,29 @@ final class CoolUtil anim2.frames = old; } + /** + * Swaps two animations on an animation controller. + * @param animation Animation controller + * @param anim1 First animation + * @param anim2 Second animation + */ + public static function swapAnims(animation:FlxAnimationController, anim1:String, anim2:String) @:privateAccess { + var flxAnim1 = animation.getByName(anim1); + animation._animations.remove(anim1); + + var flxAnim2 = animation.getByName(anim2); + animation._animations.remove(anim2); + + if (flxAnim1 != null) { + flxAnim1.name = anim2; + animation._animations.set(anim2, flxAnim1); + } + if (flxAnim2 != null) { + flxAnim2.name = anim1; + animation._animations.set(anim1, flxAnim2); + } + } + /** * Allows you to set a graphic size (ex: 150x150), with proper hitbox without a stretched sprite. * @param sprite Sprite to apply the new graphic size to diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 10c1695b..eeb12aec 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -119,7 +119,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset } for (i in variants) { - CoolUtil.switchAnimFrames(animation.getByName('singRIGHT$i'), animation.getByName('singLEFT$i')); + CoolUtil.swapAnims(animation, 'singLEFT$i', 'singRIGHT$i'); switchOffset('singLEFT$i', 'singRIGHT$i'); }