/************************************************************************************ * FileName : HeroItem.ts * Description : 英雄选择界面皮肤item * Version : v1.0.0 * CreateTime : 2024-10-22 09:55:13 * Author : * Copyright (c) since 2024 * ============================================================== * Method Description: * * ============================================================== ************************************************************************************/ import { _decorator, Component, Node, Label, SpriteFrame, Sprite } from 'cc'; import {resLoader} from "db://assets/core_tgx/base/utils/ResLoader"; import {ModuleDef} from "db://assets/scripts/ModuleDef"; import { ISkinCfg } from '../../module_basic/shared/configs/interface/ISkinCfg'; const { ccclass, property } = _decorator; @ccclass('ChooseSkinItem') export class ChooseSkinItem extends Component { // 英雄图像 @property(Node) heroIcon: Node = null; @property(Node) choose: Node = null; // 英雄唯一标识 private _heroId : number = null; private _fun : Function = null; public initData(data: ISkinCfg,callBack : Function) : void{ this._heroId = data.id; this._fun = callBack; this._initIcon(data.id); } private _initIcon(id : number) : void{ let sp : SpriteFrame = resLoader.getSpriteFrame(`res/Image/SkinIcon/skinIcon_${id}`,ModuleDef.Arean); if(sp) this.heroIcon.getComponent(Sprite).spriteFrame = sp; } public updateChooseActive(active : boolean) : void{ this.choose.active = active; } public clickHero() : void{ this._fun && this._fun(this._heroId); this.choose.active = true; } }