rank_my_info.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
  2. import { rankData } from '../../data';
  3. import { tools } from '../../tools';
  4. import { GameManager } from '../../GameManager';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('rank_my_info')
  7. export class rank_my_info extends Component {
  8. @property(Node) img_weishangbang:Node = null
  9. @property(Node) icon_number_bg:Node = null
  10. @property(Node) icon_number_img:Node = null
  11. @property(SpriteFrame) sf_rank_icon_1:SpriteFrame = null
  12. @property(SpriteFrame) sf_rank_icon_2:SpriteFrame = null
  13. @property(SpriteFrame) sf_rank_icon_3:SpriteFrame = null
  14. @property(Node) img_avatar:Node = null
  15. @property(Node) lab_nickname:Node = null
  16. @property(Node) lab_score:Node = null
  17. @property(Node) img_car:Node = null
  18. initView(data:rankData) {
  19. if(data.number>0 && data.number<=3) {
  20. this.img_weishangbang.active = false
  21. this.icon_number_bg.active = true
  22. switch (data.number) {
  23. case 1:
  24. this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_1
  25. break;
  26. case 2:
  27. this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_2
  28. break;
  29. case 3:
  30. this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_3
  31. break;
  32. default:
  33. break;
  34. }
  35. } else {
  36. this.img_weishangbang.active = true
  37. this.icon_number_bg.active = false
  38. }
  39. tools.loadRemoteImg(data.avatarUrl, (r)=>{
  40. this.img_avatar.getComponent(Sprite).spriteFrame = r.sf
  41. })
  42. this.lab_nickname.getComponent(Label).string = data.nickName
  43. this.lab_score.getComponent(Label).string = data.score + ' 分'
  44. this.img_car.getComponent(Sprite).spriteFrame = GameManager.getUserDefaultCarSf()
  45. }
  46. }