add param to hide() to auto remove the agent
This commit is contained in:
parent
b9099cd635
commit
f720acc738
2 changed files with 8 additions and 6 deletions
|
@ -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", () => {
|
||||
if(remove)
|
||||
this.remove();
|
||||
else
|
||||
this.cnv.style.display = 'none';
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue