fixed animation swapping on atlas characters

This commit is contained in:
Yoshman29
2026-01-21 20:37:13 +01:00
parent 64c29b0d86
commit e3e82e8249
2 changed files with 25 additions and 1 deletions
+24
View File
@@ -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
+1 -1
View File
@@ -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');
}