TurnableItem.ts 830 B

1234567891011121314151617181920212223242526
  1. const { ccclass, property } = cc._decorator;
  2. @ccclass
  3. export default class TurnableItem extends cc.Component {
  4. @property(cc.Sprite)
  5. icon: cc.Sprite = null;
  6. @property(cc.Label)
  7. lbl_name: cc.Label = null;
  8. public async initData(type, id:number) {
  9. this.icon.spriteFrame = await mk.loader.load('module/turnable/texture/hb' + type, cc.SpriteFrame);
  10. this.lbl_name.string = type == 1 ? "少量红包" : type == 2 ? "中量红包" : type == 3 ? "大量红包" : "6元现金" ;
  11. let outline = this.lbl_name.getComponent(cc.LabelOutline);
  12. if(outline)
  13. {
  14. if(id%2==0)
  15. {
  16. outline.color = cc.color(217, 88, 9, 255);
  17. }else
  18. outline.color = cc.color(95, 159, 12, 255);
  19. }
  20. }
  21. }