perf(英雄属性): 使用脏标签模式优化属性UI更新性能
在 HeroAttrsComp 中添加脏标签标记,仅在属性变化时更新UI 移除 HeroViewComp 中每帧不必要的UI更新调用 添加文档说明优化方案
This commit is contained in:
@@ -148,12 +148,22 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
// ✅ View 层职责:处理表现相关的逻辑
|
||||
this.processDamageQueue(); // 伤害数字显示队列
|
||||
|
||||
// ✅ 更新 UI 显示(数据由 HeroAttrSystem 更新)
|
||||
// 移除了每帧调用的 hp_show,改为仅在需要时调用
|
||||
this.hp_show();
|
||||
this.mp_show();
|
||||
this.show_shield(this.model.shield, this.model.Attrs[Attrs.SHIELD_MAX]);
|
||||
|
||||
// ✅ 按需更新 UI(脏标签模式)- 只在属性变化时更新
|
||||
if (this.model.dirty_hp) {
|
||||
this.hp_show();
|
||||
this.model.dirty_hp = false;
|
||||
}
|
||||
|
||||
if (this.model.dirty_mp) {
|
||||
this.mp_show();
|
||||
this.model.dirty_mp = false;
|
||||
}
|
||||
|
||||
if (this.model.dirty_shield) {
|
||||
this.show_shield(this.model.shield, this.model.Attrs[Attrs.SHIELD_MAX]);
|
||||
this.model.dirty_shield = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user