refactor(map): 为所有组件的onDestroy添加父类调用
统一修复组件销毁时未调用父类生命周期方法的问题,确保资源正确释放
This commit is contained in:
@@ -157,6 +157,7 @@ export class CardComp extends CCComp {
|
||||
|
||||
/** 组件销毁时解绑所有事件,防止残留回调 */
|
||||
onDestroy() {
|
||||
super.onDestroy();
|
||||
this.unbindEvents();
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ export class HInfoComp extends CCComp {
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,6 +79,7 @@ export class IBoxComp extends CCComp {
|
||||
|
||||
/** 解绑点击事件 */
|
||||
onDestroy() {
|
||||
super.onDestroy();
|
||||
if (this.node && this.node.isValid) {
|
||||
this.node.off(NodeEventType.TOUCH_END, this.onTapClose, this);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ export class MissSkillsComp extends CCComp {
|
||||
|
||||
/** 移除事件监听 */
|
||||
onDestroy() {
|
||||
super.onDestroy();
|
||||
oops.message.off(GameEvent.UseSkillCard, this.onUseSkillCard, this);
|
||||
oops.message.off(GameEvent.RemoveSkillBox, this.onRemoveSkillBox, this);
|
||||
}
|
||||
|
||||
@@ -174,6 +174,7 @@ export class MissionCardComp extends CCComp {
|
||||
|
||||
/** 组件销毁时解绑所有事件并清理英雄信息面板 */
|
||||
onDestroy() {
|
||||
super.onDestroy();
|
||||
if (this.cards_chou && this.cards_chou.isValid) {
|
||||
this.cards_chou.off(NodeEventType.TOUCH_START, this.onDrawTouchStart, this);
|
||||
this.cards_chou.off(NodeEventType.TOUCH_END, this.onDrawTouchEnd, this);
|
||||
|
||||
@@ -201,6 +201,7 @@ export class MissionComp extends CCComp {
|
||||
}
|
||||
|
||||
onDestroy(){
|
||||
super.onDestroy();
|
||||
if (this.start_btn && this.start_btn.isValid) {
|
||||
this.start_btn.off(NodeEventType.TOUCH_END, this.onStartFightBtnClick, this);
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ export class MissionHeroCompComp extends CCComp {
|
||||
}
|
||||
|
||||
onDestroy(){
|
||||
super.onDestroy();
|
||||
// 清理全部监听
|
||||
oops.message.off(GameEvent.CallHero,this.call_hero,this)
|
||||
oops.message.off("PhasePrepareStart",this.fight_ready,this)
|
||||
|
||||
@@ -66,7 +66,7 @@ export class RanksComp extends CCComp {
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/** 关闭排行榜弹窗 */
|
||||
|
||||
@@ -92,6 +92,7 @@ export class SkillBoxComp extends CCComp {
|
||||
|
||||
/** 销毁时移除所有事件监听并通知槽位管理器回收 */
|
||||
onDestroy() {
|
||||
super.onDestroy();
|
||||
oops.message.off(GameEvent.FightStart, this.onFightStart, this);
|
||||
oops.message.off(GameEvent.MissionEnd, this.onMissionEnd, this);
|
||||
if (this.node && this.node.isValid) {
|
||||
|
||||
@@ -113,6 +113,7 @@ export class TalentItemComp extends CCComp {
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
super.onDestroy();
|
||||
if (this.btn_upgrade && this.btn_upgrade.node && this.btn_upgrade.node.isValid) {
|
||||
this.btn_upgrade.node.off(Button.EventType.CLICK, this.onUpgradeClicked, this);
|
||||
}
|
||||
|
||||
@@ -254,6 +254,7 @@ export class TalentsComp extends CCComp {
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
super.onDestroy();
|
||||
mLogger.log(this.debugMode, 'TalentsComp', "释放界面");
|
||||
if (this.btn_reset && this.btn_reset.node && this.btn_reset.node.isValid) {
|
||||
this.btn_reset.node.off(Button.EventType.CLICK, this.onResetClicked, this);
|
||||
|
||||
@@ -598,6 +598,7 @@ export class VictoryComp extends CCComp {
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
super.onDestroy();
|
||||
mLogger.log(this.debugMode, 'VictoryComp', "释放胜利界面");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user