import { _decorator, Sprite, Label} from 'cc'; import ListItem from '../../third/ListItem'; import { ResUtil } from '../../utils/ResUtil'; import i18n from '../../core/i18n/runtime-scripts/LanguageData'; const { ccclass, property } = _decorator; //商店数据 @ccclass('StoreItem') export class StoreItem extends ListItem { @property({ type: Sprite, tooltip: "道具图标" }) public s_icon: Sprite; @property({ type: Label, tooltip: "道具描述" }) public s_des_lable: Label; @property({ type: Label, tooltip: "看广告的次数" }) public video_label: Label; public data: any = null; public cb?: Function = null; /** * 看视频 */ private clikItemVideo(){ if(!this.data)return; this.cb?.(this.data,this.s_icon.node); } /** * 数据填充 * @param data 数据 * @param cb 回调 */ public init(data: any,cb?: Function){ if(!data)return; this.data = data; this.cb = cb; //敌人投降 ResUtil.setSpriteFrame(data.icon,this.s_icon); //道具描述 this.s_des_lable.string = i18n.isZh ? data.des : data.des_lang; //看广告的次数 this.video_label.string = `${data.price_2}/${data.alreadyVideo}`; } }