Compose.ts 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import { _decorator, Component, sp, Label, Sprite, SpriteFrame } from "cc";
  2. import { ResourceLoader } from "../../core/resourceManager/ResourceLoader";
  3. import { Window } from "../../core/ui/window/Window";
  4. import { UserHero } from "../UserHeroData";
  5. const { ccclass, property } = _decorator;
  6. /**
  7. * 合成成功提示
  8. * @author 袁浩
  9. */
  10. @ccclass("Compose")
  11. export class Compose extends Component {
  12. @property({ tooltip: "武将骨骼动画组件", type: sp.Skeleton })
  13. public body: sp.Skeleton;
  14. @property({ tooltip: "武将名称", type: Label })
  15. public nameLabel: Label;
  16. @property({ tooltip: "阵营图标", type: Sprite })
  17. public campIcon: Sprite;
  18. @property({ tooltip: "所有阵营图标", type: [SpriteFrame] })
  19. public campIconList: SpriteFrame[] = [];
  20. start() {
  21. let data: UserHero = this.getComponent(Window).params[0];
  22. this.initUI(data);
  23. }
  24. private async initUI(data: UserHero) {
  25. this.nameLabel.string = data.client.name;
  26. this.campIcon.spriteFrame = this.campIconList[data.client.camp - 1];
  27. this.body.skeletonData = await this.getComponent(ResourceLoader).load(`spine/hero/${data.client.hero_res}`, sp.SkeletonData);
  28. this.body.setAnimation(0, "idle", true);
  29. }
  30. }