import i18n from "../../i18n/i18n"; import Main from "../../main/Main"; /** * 装备附加属性 */ const {ccclass, property} = cc._decorator; @ccclass export default class EquipViewAttr extends cc.Component { @property(cc.Sprite) mIcon: cc.Sprite = null; @property(cc.Label) mName: cc.Label = null; @property(cc.Label) mValue: cc.Label = null; /** * * @param main * @param attr {K:id,V:value} */ public init(main:Main,attr:any){ let sManage = main.sManage; let attrData = sManage.getEquipAttrById(attr.K); if(attrData){ this.mName.string = i18n.t(attrData.name); this.mValue.string = '+'+attr.V+'%'; cc.resources.load('icon/attr/attribute_icon_'+attr.K, cc.SpriteFrame, (err, spriteFrame:cc.SpriteFrame) =>{ if(err){ cc.error(err); }else{ this.mIcon.spriteFrame = spriteFrame; } } ); } } }