//已TS化,測試無誤可刪除原JS代碼 import GameModel from "../../ts/core/GameModel"; import GameUtil from "../../ts/core/GameUtil"; import JSUtil = require("../../ts/core/JSUtil"); const { ccclass, property } = cc._decorator; @ccclass export default class ChatTasktem extends cc.Component { @property(cc.Sprite) item_icon: cc.Sprite = null; @property(cc.SpriteAtlas) emojiAtlas: cc.SpriteAtlas = null; itemInfo: any = null; isEmpty: boolean = false onLoad() { } loadInfo(info: any) { this.itemInfo = info; this.itemInfo.type = 0; this.item_icon.spriteFrame = this.emojiAtlas.getSpriteFrame(('000' + info.index).substr(-3) + '0000'); this.isEmpty = this.item_icon.spriteFrame == null || this.item_icon.spriteFrame == undefined; } mCallback: any; setCallback(callback) { this.mCallback = callback; } onPetClick() { if (this.mCallback) { this.mCallback(this.itemInfo); } } }