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", () => {});
}
hide() {
// 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)
hide(remove: boolean = false) {
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");
let agent = msagent.agentParseCharacterTestbed(new Uint8Array(buffer));
// destroy the previous agent
if(w.agent != null) {
w.agent.hide();
w.agent.hide(true);
}
w.agent = agent;