refactor: 移除内存面板并添加显示控制标志
在 MissionComp 的 onLoad 方法中初始化 showMemoryPanel 为 false,并调用 removeMemoryPanel 来销毁内存面板节点。 同时,将 update 方法中对 updateMemoryPanel 的调用移除,以停止面板的持续更新。
This commit is contained in:
@@ -77,12 +77,13 @@ export class MissionComp extends CCComp {
|
||||
// 记录已触发的特殊刷怪索引
|
||||
|
||||
onLoad(){
|
||||
this.showMemoryPanel = false
|
||||
this.on(GameEvent.MissionStart,this.mission_start,this)
|
||||
// this.on(GameEvent.HeroDead,this.do_hero_dead,this)
|
||||
// this.on(GameEvent.FightEnd,this.fight_end,this)
|
||||
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
||||
this.on(GameEvent.DO_AD_BACK,this.do_ad,this)
|
||||
this.initMemoryPanel()
|
||||
this.removeMemoryPanel()
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if(!smc.mission.play) return
|
||||
@@ -94,7 +95,6 @@ export class MissionComp extends CCComp {
|
||||
this.FightTime-=dt
|
||||
// 检查特殊刷怪时间
|
||||
this.update_time();
|
||||
this.updateMemoryPanel(dt);
|
||||
}
|
||||
}
|
||||
update_time(){
|
||||
@@ -331,6 +331,15 @@ export class MissionComp extends CCComp {
|
||||
this.memoryLabel = label;
|
||||
}
|
||||
|
||||
private removeMemoryPanel() {
|
||||
const panel = this.time_node?.getChildByName("mem_panel");
|
||||
if (panel) {
|
||||
panel.destroy();
|
||||
}
|
||||
this.memoryLabel = null;
|
||||
this.lastMemoryText = "";
|
||||
}
|
||||
|
||||
|
||||
private updateMemoryPanel(dt: number) {
|
||||
if (!this.showMemoryPanel || !this.memoryLabel) return;
|
||||
|
||||
Reference in New Issue
Block a user