refactor(tooltip): 优化提示系统使用对象池并改进动画效果

重构提示系统,引入对象池管理节点提升性能,改进动画效果包括缩放、位移和淡出,调整提示位置和层级防止重叠,修复父节点翻转时的显示问题
This commit is contained in:
walkpan
2026-01-02 17:27:53 +08:00
parent ebd67472c7
commit c40414173d
5 changed files with 266 additions and 212 deletions

View File

@@ -266,20 +266,26 @@ export class HeroViewComp extends CCComp {
}
/** 技能提示 */
private tooltip(type: number = 1, value: string = "", s_uuid: number = 1001, y: number = 120) {
let tip = ecs.getEntity<Tooltip>(Tooltip);
private tooltip(type: number = 1, value: string = "", s_uuid: number = 1001, y: number = 50) {
let pos = v3(0, 60);
pos.y = pos.y + y;
tip.load(pos, type, value, s_uuid, this.node);
Tooltip.load(pos, type, value, s_uuid, this.node);
}
/** 血量提示(伤害数字) */
private hp_tip(type: number = 1, value: string = "", s_uuid: number = 1001, y: number = 120) {
let tip = ecs.getEntity<Tooltip>(Tooltip);
private hp_tip(type: number = 1, value: string = "", s_uuid: number = 1001, y: number = 0) {
let x = this.node.position.x;
let ny = this.node.getComponent(UITransform).height + y;
// 获取怪物高度的一半,定位到中心点
let halfHeight = 0;
const transform = this.node.getComponent(UITransform);
if (transform) {
halfHeight = transform.height / 2;
}
// 起点设为怪物中心位置 + 20偏移
let ny = this.node.position.y + halfHeight + 20;
let pos = v3(x, ny, 0);
tip.load(pos, type, value, s_uuid, this.node.parent);
Tooltip.load(pos, type, value, s_uuid, this.node.parent);
}
/** 护盾吸收提示 */