refactor(tooltip): 优化提示系统使用对象池并改进动画效果
重构提示系统,引入对象池管理节点提升性能,改进动画效果包括缩放、位移和淡出,调整提示位置和层级防止重叠,修复父节点翻转时的显示问题
This commit is contained in:
@@ -4,11 +4,19 @@ import { BoxSet } from "../common/config/GameSet";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { TooltipCom } from "./TooltipCom";
|
||||
import { instantiate, Node, Prefab, Vec3 ,tween, v3,animation,Label,resources,SpriteFrame,Sprite} from "cc";
|
||||
import { instantiate, Node, Prefab, Vec3 ,tween, v3,animation,Label,resources,SpriteFrame,Sprite, NodePool} from "cc";
|
||||
|
||||
/** Skill 模块 */
|
||||
@ecs.register(`Tooltip`)
|
||||
export class Tooltip extends ecs.Entity {
|
||||
/** 对象池 */
|
||||
static pool: NodePool = new NodePool();
|
||||
|
||||
/** 回收节点 */
|
||||
static put(node: Node) {
|
||||
this.pool.put(node);
|
||||
}
|
||||
|
||||
/** ---------- 数据层 ---------- */
|
||||
// SkillModel!: SkillModelComp;
|
||||
|
||||
@@ -29,22 +37,23 @@ export class Tooltip extends ecs.Entity {
|
||||
this.remove(TooltipCom);
|
||||
super.destroy();
|
||||
}
|
||||
load(pos: Vec3 = Vec3.ZERO,type:number=1,vaule:string="",s_uuid:number=1001,parent:any=null,cd:number=1) {
|
||||
|
||||
var path = "game/skill/buff/tooltip";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.parent = parent;
|
||||
if(parent.scale.x < 0){
|
||||
node.setScale(-node.scale.x, node.scale.y, 0);
|
||||
static load(pos: Vec3 = Vec3.ZERO,type:number=1,vaule:string="",s_uuid:number=1001,parent:any=null,cd:number=1) {
|
||||
let node: Node;
|
||||
if (Tooltip.pool.size() > 0) {
|
||||
node = Tooltip.pool.get()!;
|
||||
} else {
|
||||
var path = "game/skill/buff/tooltip";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
node = instantiate(prefab);
|
||||
}
|
||||
node.setPosition(pos)
|
||||
|
||||
node.parent = parent;
|
||||
node.setPosition(pos);
|
||||
node.active = true;
|
||||
|
||||
var sv = node.getComponent(TooltipCom)!;
|
||||
// console.log("load tooltip type",type,vaule,s_uuid);
|
||||
sv.stype = type;
|
||||
sv.value = vaule;
|
||||
sv.s_uuid = s_uuid;
|
||||
sv.alive_time = 0.5;
|
||||
this.add(sv)
|
||||
sv.init(type, vaule, s_uuid);
|
||||
|
||||
// this.add(sv); // 不要添加到单例实体上,否则会覆盖或导致单例被销毁
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user