From c94255cc024e4f9e2c61f18bee614826d33ce2b5 Mon Sep 17 00:00:00 2001 From: walkpan Date: Sat, 3 Jan 2026 09:17:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=8B=B1=E9=9B=84?= =?UTF-8?q?=E9=94=80=E6=AF=81=E5=92=8C=E4=BB=BB=E5=8A=A1=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E6=AE=8B=E7=95=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在Hero.ts中增加销毁节点的逻辑,防止视觉残留 在MissionComp.ts中清理回调函数和组件,避免上一局残留影响新局 --- assets/script/game/hero/Hero.ts | 6 ++++++ assets/script/game/map/MissionComp.ts | 5 +++++ 2 files changed, 11 insertions(+) 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