refactor(hero): 移除视图层直接更新逻辑,使用脏标签机制
- 在HeroViewComp中移除hp_show和mp_show的直接调用 - 在HeroAttrsComp中不再直接调用视图层方法 - 使用脏标签机制(dirty flag)来触发UI更新
This commit is contained in:
@@ -81,7 +81,7 @@ export class HeroViewComp extends CCComp {
|
||||
collider.enabled = true; // 先禁
|
||||
collider.group = this.box_group; // 设置为英雄组
|
||||
}
|
||||
|
||||
|
||||
},0.1)
|
||||
// let anm = this.node.getChildByName("anm")
|
||||
// anm.setScale(anm.scale.x*0.8,anm.scale.y*0.8);
|
||||
@@ -312,17 +312,22 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
|
||||
health(hp: number = 0) {
|
||||
// 生命值更新由 Model 层处理,这里只负责视图表现
|
||||
// ✅ 仅显示特效和提示,不调用 hp_show()
|
||||
this.heathed();
|
||||
this.hp_tip(TooltipTypes.health, hp.toFixed(0));
|
||||
this.top_node.active=true
|
||||
this.hp_show();
|
||||
this.top_node.active = true;
|
||||
|
||||
// ❌ 移除:UI更新由脏标签机制处理
|
||||
// this.hp_show();
|
||||
}
|
||||
|
||||
mp_add(mp: number = 0) {
|
||||
// 生命值更新由 Model 层处理,这里只负责视图表现
|
||||
// ✅ 仅显示提示,不调用 mp_show()
|
||||
this.hp_tip(TooltipTypes.addmp, mp.toFixed(0));
|
||||
this.top_node.active=true
|
||||
this.mp_show();
|
||||
this.top_node.active = true;
|
||||
|
||||
// ❌ 移除:UI更新由脏标签机制处理
|
||||
// this.mp_show();
|
||||
}
|
||||
|
||||
alive(){
|
||||
|
||||
Reference in New Issue
Block a user