fixed animation swapping on atlas characters
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user