EquipViewAttr.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import i18n from "../../i18n/i18n";
  2. import Main from "../../main/Main";
  3. /**
  4. * 装备附加属性
  5. */
  6. const {ccclass, property} = cc._decorator;
  7. @ccclass
  8. export default class EquipViewAttr extends cc.Component {
  9. @property(cc.Sprite)
  10. mIcon: cc.Sprite = null;
  11. @property(cc.Label)
  12. mName: cc.Label = null;
  13. @property(cc.Label)
  14. mValue: cc.Label = null;
  15. /**
  16. *
  17. * @param main
  18. * @param attr {K:id,V:value}
  19. */
  20. public init(main:Main,attr:any){
  21. let sManage = main.sManage;
  22. let attrData = sManage.getEquipAttrById(attr.K);
  23. if(attrData){
  24. this.mName.string = i18n.t(attrData.name);
  25. this.mValue.string = '+'+attr.V+'%';
  26. cc.resources.load('icon/attr/attribute_icon_'+attr.K, cc.SpriteFrame, (err, spriteFrame:cc.SpriteFrame) =>{
  27. if(err){
  28. cc.error(err);
  29. }else{
  30. this.mIcon.spriteFrame = spriteFrame;
  31. }
  32. } );
  33. }
  34. }
  35. }