diff --git a/msagent.js/src/agent.ts b/msagent.js/src/agent.ts index a8e61da..db37fec 100644 --- a/msagent.js/src/agent.ts +++ b/msagent.js/src/agent.ts @@ -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'; + }); } } diff --git a/webapp/src/ts/testbed.ts b/webapp/src/ts/testbed.ts index 4ac0b63..54fc0ca 100644 --- a/webapp/src/ts/testbed.ts +++ b/webapp/src/ts/testbed.ts @@ -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;