Skip to content

Commit 535e702

Browse files
authored
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
1 parent 31a01be commit 535e702

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

source/funkin/game/Character.hx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,19 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
108108
}
109109

110110
public function swapLeftRightAnimations() {
111-
CoolUtil.switchAnimFrames(animation.getByName('singRIGHT'), animation.getByName('singLEFT'));
112-
CoolUtil.switchAnimFrames(animation.getByName('singRIGHTmiss'), animation.getByName('singLEFTmiss'));
111+
// Find all "alternate" poses
112+
var variants = ['']; // Pre-fill with empty string
113+
var pose = 'singRIGHT'; // Any "sing" animation string could work, really
114+
for (a in xml.nodes.anim) {
115+
if (a.att.name != pose && StringTools.startsWith(a.att.name, pose)) {
116+
variants.push(a.att.name.substring(pose.length));
117+
}
118+
}
113119

114-
switchOffset('singLEFT', 'singRIGHT');
115-
switchOffset('singLEFTmiss', 'singRIGHTmiss');
120+
for (i in variants) {
121+
CoolUtil.switchAnimFrames(animation.getByName('singRIGHT$i'), animation.getByName('singLEFT$i'));
122+
switchOffset('singLEFT$i', 'singRIGHT$i');
123+
}
116124

117125
__swappedLeftRightAnims = true;
118126
}

0 commit comments

Comments
 (0)