diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 05083281..531dacfd 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -29,6 +29,12 @@ export class Hero extends ecs.Entity { } destroy(): void { + // 销毁节点,防止视觉残留 + const view = this.get(HeroViewComp); + if (view && view.node && view.node.isValid) { + view.node.destroy(); + } + this.remove(HeroViewComp); this.remove(HeroAttrsComp); this.remove(HeroSkillsComp); diff --git a/assets/script/game/map/MissionComp.ts b/assets/script/game/map/MissionComp.ts index 398023b3..88dde066 100644 --- a/assets/script/game/map/MissionComp.ts +++ b/assets/script/game/map/MissionComp.ts @@ -84,6 +84,11 @@ export class MissionComp extends CCComp { async mission_start(){ + // 防止上一局的 fight_end 延迟回调干扰新局 + this.unscheduleAllCallbacks(); + // 确保清理上一局的残留实体 + this.cleanComponents(); + // console.log("[MissionComp] ** 1 ** mission_start") oops.message.dispatchEvent(GameEvent.FightReady) this.node.active=true