add param to hide() to auto remove the agent

This commit is contained in:
Lily Tsuru 2024-07-09 23:42:43 -04:00
parent b9099cd635
commit f720acc738
2 changed files with 8 additions and 6 deletions

View file

@ -176,12 +176,13 @@ export class Agent {
this.playAnimationByName("Show", () => {}); this.playAnimationByName("Show", () => {});
} }
hide() { hide(remove: boolean = false) {
// TODO: play the hide animation (then clear the canvas)
// (if not constructing. We can probably just duplicate this one line and put it in the constructor tbh)
this.playAnimationByName("Hide", () => { this.playAnimationByName("Hide", () => {
this.cnv.style.display = 'none'; if(remove)
this.remove();
else
this.cnv.style.display = 'none';
}); });
} }
} }

View file

@ -11,8 +11,9 @@ 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));
// destroy the previous agent
if(w.agent != null) { if(w.agent != null) {
w.agent.hide(); w.agent.hide(true);
} }
w.agent = agent; w.agent = agent;