44 lines
1.8 KiB
TypeScript
44 lines
1.8 KiB
TypeScript
import { instantiate, Label, Prefab, resources, Sprite, SpriteAtlas } from "cc";
|
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
import { HeroSelectComp } from "./HeroSelectComp";
|
|
import { smc } from "../common/SingletonModuleComp";
|
|
import { HeroInfo } from "../common/config/heroSet";
|
|
|
|
/** HeroSelect 模块 */
|
|
@ecs.register(`HeroSelect`)
|
|
export class HeroSelect extends ecs.Entity {
|
|
|
|
protected init() {
|
|
// this.addComponents<ecs.Comp>();
|
|
}
|
|
load(uuid:number=101,parent:any) {
|
|
// var path = "game/monster/"+prefab_path;
|
|
var path = "game/gui/hero_set";
|
|
// var icon_path = "game/heros/herois"
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var node = instantiate(prefab);
|
|
let slv = node.getChildByName("slv");
|
|
node.parent = parent;
|
|
node.getChildByName("name").getComponent(Label).string = HeroInfo[uuid].name
|
|
// resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
|
// const sprite = node.getChildByName("Mask").getChildByName("hero").getComponent(Sprite);
|
|
// sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
|
|
// });
|
|
var path = "game/heros/uiheros/"+HeroInfo[uuid].path;
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var snode = instantiate(prefab);
|
|
snode.parent = node.getChildByName("Mask")
|
|
let hcc = node.getComponent(HeroSelectComp)!;
|
|
hcc.h_uuid = uuid;
|
|
hcc.update_data();
|
|
this.add(hcc);
|
|
}
|
|
|
|
/** 模块资源释放 */
|
|
destroy() {
|
|
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
|
super.destroy();
|
|
}
|
|
}
|