add remove() to remove from dom (TODO: will need to handle wordballoon)

This commit is contained in:
Lily Tsuru 2024-07-09 23:35:30 -04:00
parent 803c63f1f9
commit 29d6213134
2 changed files with 9 additions and 0 deletions

View file

@ -110,6 +110,10 @@ export class Agent {
parent.appendChild(this.cnv); parent.appendChild(this.cnv);
} }
remove() {
this.cnv.parentElement?.removeChild(this.cnv);
}
// add promise versions later. // add promise versions later.
playAnimation(index: number, finishCallback: () => void) { playAnimation(index: number, finishCallback: () => void) {
if(this.animState != null) if(this.animState != null)

View file

@ -10,6 +10,11 @@ input.addEventListener("change", async () => {
console.log("About to parse character"); console.log("About to parse character");
let agent = msagent.agentParseCharacterTestbed(new Uint8Array(buffer)); let agent = msagent.agentParseCharacterTestbed(new Uint8Array(buffer));
if(w.agent != null) {
w.agent.hide();
}
w.agent = agent; w.agent = agent;
agent.addToDom(document.body); agent.addToDom(document.body);