ResultItem.ts 1.0 KB

123456789101112131415161718192021
  1. import { _decorator, Component, Node, Sprite, Label, SpriteFrame } from 'cc';
  2. import { ResourceLoader } from '../../core/resourceManager/ResourceLoader';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('ResultItem')
  5. export class ResultItem extends Component {
  6. @property({ type: ResourceLoader, tooltip: "资源加载组件" }) res: ResourceLoader;
  7. @property({ type: Sprite, tooltip: "图标" }) icon: Sprite;
  8. @property({ type: Sprite, tooltip: "碎片图标" }) chipIcon: Sprite;
  9. @property({ type: Label, tooltip: "数量" }) countLabel: Label;
  10. @property({ type: Sprite, tooltip: "底框" }) bg: Sprite;
  11. public async setData(path: string, count: string, isChip = false, color: number = 2, name: string = "") {
  12. this.countLabel.string = name + "x" + count;
  13. this.chipIcon.node.active = isChip;
  14. this.icon.spriteFrame = await this.res.load<SpriteFrame>(path, SpriteFrame);
  15. this.bg.spriteFrame = await this.res.load<SpriteFrame>("images/general/texture/zy_head" + color + "/spriteFrame", SpriteFrame);
  16. }
  17. }