NewRewardWindow_1.ts 1.0 KB

12345678910111213141516171819202122232425
  1. import { _decorator, Component, Node, Sprite, Label, ImageAsset, SpriteFrame, Texture2D } from 'cc';
  2. import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils';
  3. import { g } from '../../Data/g';
  4. import { ISJSB, platform } from '../../Data/platform';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('NewRewardWindow1')
  7. export class NewRewardWindow1 extends Component {
  8. @property({ type: Sprite, tooltip: "用户头像" }) head: Sprite;
  9. @property({ type: Label, tooltip: "用户昵称" }) nickName: Label;
  10. async start() {
  11. platform.reportThinking("login", JSON.stringify({ guide: "first_gift" }));
  12. if (ISJSB) {
  13. let img = await ResourcesUtils.loadRemote<ImageAsset>(g.userData.avator, { ext: ".png" }, this);
  14. const spriteFrame = new SpriteFrame();
  15. const texture = new Texture2D();
  16. texture.image = img;
  17. spriteFrame.texture = texture;
  18. this.head.spriteFrame = spriteFrame;
  19. }
  20. this.nickName.string = g.userData.nickName;
  21. }
  22. }