1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { _decorator, Sprite, Label, ProgressBar } from 'cc';
- import ListItem from '../../third/ListItem';
- import { ResUtil } from '../../utils/ResUtil';
- const { ccclass, property } = _decorator;
- //枪的属性数据
- /*attr_name attr_value attr_icon max_value attribute_lang*/
- @ccclass('GunAttrItem')
- export class GunAttrItem extends ListItem {
- @property({ type: Sprite, tooltip: "枪的属性图片" })
- public attr_sp: Sprite;
- @property({ type: ProgressBar, tooltip: "属性值的最大进度" })
- public progressBar: ProgressBar;
- @property({ type: Label, tooltip: "属性值的数据文本" })
- public atts_label: Label;
- @property({ type: Label, tooltip: "枪的属性多语言名字" })
- public attribute_lang_lable: Label;
- public data: any = null;
- public start() {
- }
- /**
- * 数据填充
- * @param data 数据
- * @param cb 回调
- */
- public init(data: any,cb?: Function){
- if(!data)return;
- this.data = data;
- //设置属性图标
- ResUtil.setSpriteFrame(data.attr_icon, this.attr_sp);
- // 设置进度条 当前值/最大值
- this.progressBar.progress = data.attr_value / data.totalValue;
- //设置属性数值文本
- this.atts_label.string = `${data.attr_value}/${data.totalValue}`;
- //设置多语言属性名称
- this.attribute_lang_lable.string = data.attribute_lang;
- }
- }
|