heros 卡片 细节完善 思考下步内容

This commit is contained in:
2024-11-19 10:52:20 +08:00
parent ce8b47de7d
commit e89f590979
6 changed files with 694 additions and 529 deletions

View File

@@ -1,4 +1,4 @@
import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,resources,Sprite,SpriteAtlas,UITransform,v3 } from "cc";
import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,ProgressBar,resources,Sprite,SpriteAtlas,UITransform,v3 } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { smc } from "../common/SingletonModuleComp";
@@ -13,16 +13,32 @@ const { ccclass, property } = _decorator;
@ecs.register('HCardComp', false)
export class HCardComp extends CCComp {
hi: number = 0;
heros:any = []
icon:any=[]
hc_name:any=[]
ap:any=[]
hp:any=[]
life:any=[]
protected onLoad(): void {
}
start() {
let heros:any= ecs.query(ecs.allOf(HeroModelComp));
this.node.getChildByName("name").getComponent(Label)!.string = heros[this.hi].HeroView.hero_name
this.heros= ecs.query(ecs.allOf(HeroModelComp));
this.hc_name=this.node.getChildByName("name").getComponent(Label)!
this.icon=this.node.getChildByName("icon").getComponent(Sprite)!
this.hp=this.node.getChildByName("hp").getChildByName("num").getComponent(Label)!
this.ap=this.node.getChildByName("ap").getChildByName("num").getComponent(Label)!
this.life=this.node.getChildByName("life").getComponent(ProgressBar)!
this.hc_name.string= this.heros[this.hi].HeroView.hero_name
console.log("hcard start")
}
protected update(dt: number): void {
this.hp.string=this.heros[this.hi].HeroView.hp_max
this.ap.string=this.heros[this.hi].HeroView.ap
this.life.progress=this.heros[this.hi].HeroView.hp/this.heros[this.hi].HeroView.hp_max
}
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
console.log("hcard reset");