add playAnimationByName() api

This commit is contained in:
Lily Tsuru 2024-07-09 23:26:12 -04:00
parent 3845f1c1a7
commit 8d029c682f
2 changed files with 7 additions and 1 deletions

View file

@ -118,6 +118,12 @@ export class Agent {
this.animState.play();
}
playAnimationByName(name: String) {
let index = this.data.animInfo.findIndex((n) => n.name == name);
if(index !== -1)
this.playAnimation(index);
}
animationFinished() {
this.animState = null;
}

View file

@ -14,7 +14,7 @@ input.addEventListener("change", async () => {
agent.show();
agent.playAnimation(0);
agent.playAnimationByName("Show");
console.log("parsed character");
})