51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
import { instantiate, Prefab, Vec3 } from "cc";
|
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { InfoBoxCom } from "./InfoBoxCom";
|
|
import { smc } from "../common/SingletonModuleComp";
|
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
|
|
/** InfoBox 模块 */
|
|
@ecs.register(`InfoBox`)
|
|
export class InfoBox extends ecs.Entity {
|
|
/** ---------- 数据层 ---------- */
|
|
// InfoBoxModel!: InfoBoxModelComp;
|
|
|
|
/** ---------- 业务层 ---------- */
|
|
// InfoBoxBll!: InfoBoxBllComp;
|
|
|
|
/** ---------- 视图层 ---------- */
|
|
InfoBoxView!: InfoBoxCom
|
|
|
|
/** 实始添加的数据层组件 */
|
|
protected init() {
|
|
// this.addComponents<ecs.Comp>();
|
|
}
|
|
load(pos: Vec3 = Vec3.ZERO,uuid:number=101,prefab_path:string) {
|
|
var path = "game/gui/"+prefab_path;
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var node = instantiate(prefab);
|
|
var scene = smc.map.MapView.scene;
|
|
node.parent = scene.SkillLayer!.node!;
|
|
node.setPosition(pos)
|
|
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
|
// const url = 'game/heros/player';
|
|
// resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
|
// const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
|
|
|
// sprite.spriteFrame = atlas.getSpriteFrame(RoleSet[uuid].path);
|
|
// });
|
|
// var rv = node.getComponent(MonsterViewComp)!;
|
|
// this.add(rv);
|
|
var mv = node.getComponent(InfoBoxCom)!;
|
|
this.add(mv);
|
|
|
|
}
|
|
/** 模块资源释放 */
|
|
destroy() {
|
|
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
|
this.remove(InfoBoxCom);
|
|
super.destroy();
|
|
}
|
|
}
|
|
|