fix(hero view): 清理英雄节点残留特效子节点

修复对象池复用英雄节点时,残留上一个单位的特效到新单位的问题
This commit is contained in:
panFD
2026-09-14 17:09:57 +08:00
parent b63572c383
commit 5583dca2b6

View File

@@ -544,6 +544,15 @@ export class HeroViewComp extends CCComp {
// 清理残留的定时器和缓动 // 清理残留的定时器和缓动
this.unscheduleAllCallbacks(); this.unscheduleAllCallbacks();
Tween.stopAllByTarget(this.node); Tween.stopAllByTarget(this.node);
// 清理挂在节点下未播完的特效子节点(冰冻/击晕/受击等),
// 防止对象池复用节点时把上一个单位的特效带到新单位身上。
// 判定依据:特效由 spawnTimedFx/spawnAnimEndFx 实例化并挂 timedCom/oneCom,
// 预制体自带子节点(anm/top 等)无这两个组件,不受影响。
for (const child of [...this.node.children]) {
if (child.getComponent(timedCom) || child.getComponent(oneCom)) {
child.destroy();
}
}
this.topBar.reset(); this.topBar.reset();
// 清理碰撞器事件监听 // 清理碰撞器事件监听