Expand animation swapping function to support all variants (#822)

* Expanding animation swapping function to support all variants

* More straight-forward variable names, switching to string interpolation
This commit is contained in:
Jurta
2025-11-18 07:51:30 +07:00
committed by GitHub
parent 31a01bea97
commit 535e702bc2
+12 -4
View File
@@ -108,11 +108,19 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
}
public function swapLeftRightAnimations() {
CoolUtil.switchAnimFrames(animation.getByName('singRIGHT'), animation.getByName('singLEFT'));
CoolUtil.switchAnimFrames(animation.getByName('singRIGHTmiss'), animation.getByName('singLEFTmiss'));
// Find all "alternate" poses
var variants = ['']; // Pre-fill with empty string
var pose = 'singRIGHT'; // Any "sing" animation string could work, really
for (a in xml.nodes.anim) {
if (a.att.name != pose && StringTools.startsWith(a.att.name, pose)) {
variants.push(a.att.name.substring(pose.length));
}
}
switchOffset('singLEFT', 'singRIGHT');
switchOffset('singLEFTmiss', 'singRIGHTmiss');
for (i in variants) {
CoolUtil.switchAnimFrames(animation.getByName('singRIGHT$i'), animation.getByName('singLEFT$i'));
switchOffset('singLEFT$i', 'singRIGHT$i');
}
__swappedLeftRightAnims = true;
}