import { _decorator, Component, Label, Node, Sprite } from 'cc'; import { ModulerBase } from '../GameFrameWork/ModulerBase'; import { resMgr } from '../../Frames/ResourcesMgr'; import { RoleData } from '../../DataItem/ItemData'; const { ccclass, property } = _decorator; @ccclass('RoleCard') export class RoleCard extends Component { typeRole: Node = null; roleImg: Node = null; atk: Node = null; atkLength: Node = null; hp: Node = null; moveSpeed: Node = null; protected onLoad(): void { this.typeRole = this.node.getChildByName("Types_of_Role"); this.roleImg = this.node.getChildByName("Role_Img"); this.atk = this.node.getChildByPath("Attribute/Atk"); this.hp = this.node.getChildByPath("Attribute/Hp"); this.atkLength = this.node.getChildByPath("Attribute/AtkLength"); this.moveSpeed = this.node.getChildByPath("Attribute/MoveSpeed"); } init(id: number, data: RoleData[]){ this.typeRole.getComponent(Sprite).spriteFrame = resMgr.getSpriteFrame("font_047"); this.roleImg.getComponent(Sprite).spriteFrame = resMgr.getSpriteFrame("hero_1"); this.atk.getComponent(Label).string = `攻 击:${data[id].atk}` ; this.hp.getComponent(Label).string = `血 量:${data[id].hp}` ; this.atkLength.getComponent(Label).string = `攻击距离:${data[id].atkLength}` ; this.moveSpeed.getComponent(Label).string = `移动速度:${data[id].moveSpeed}` ; } }