//已TS化,測試無誤可刪除原JS代碼 import GameModel from "../../ts/core/GameModel"; import GameUtil from "../../ts/core/GameUtil"; import ItemUtil from "../../ts/core/ItemUtil"; const {ccclass, property} = cc._decorator; @ccclass export default class ChatAppelItem extends cc.Component { @property(cc.Sprite) itemIcon: cc.Sprite = null; @property(cc.Label) nameLab: cc.Label = null ; @property(cc.Label) petLevel: cc.Label =null; @property(cc.Node) onbattleIcon: cc.Node = null; @property(cc.Node) selectedNode: cc.Node = null; itemInfo :any =null; onLoad() { } loadInfo(info:any) { this.itemInfo = info; this.itemInfo.type = info.mType; this.itemInfo.id = info.petid; this.itemIcon.spriteFrame = ItemUtil.getItemIcon(info.resid || info.resId); this.nameLab.string = info.name; if(info.mType == 3){ GameUtil.setReliveLabel(this.petLevel,1,info.relive,info.level); }else{ this.petLevel.string = info.level+"級"; } } mCallback: any; setCallback(callback) { this.mCallback = callback; } onPetClick() { if(this.mCallback){ this.mCallback(this.itemInfo); } } }