TaskEnemyItem.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import { _decorator, Vec3,Node, Sprite, Label} from 'cc';
  2. import ListItem from '../../third/ListItem';
  3. import { ResUtil } from '../../utils/ResUtil';
  4. const { ccclass, property } = _decorator;
  5. //射击界面的任务Item数据
  6. @ccclass('TaskEnemyItem')
  7. export class TaskEnemyItem extends ListItem {
  8. @property({ type: Sprite, tooltip: "任务敌人头像" })
  9. public enemy_header: Sprite;
  10. @property({ type: Label, tooltip: "剩余敌人数量" })
  11. public num_label: Label;
  12. @property({ type: Label, tooltip: "敌人名字" })
  13. public enemy_name_label: Label;
  14. public data: any = null;
  15. /**
  16. * 数据填充
  17. * @param data 敌人数据
  18. * @param cb 回调
  19. */
  20. public init(data: any,cb?: Function){
  21. if(!data)return;
  22. this.data = data;
  23. //敌人头像
  24. ResUtil.setSpriteFrame(data.headshot,this.enemy_header);
  25. //剩余敌人数量
  26. this.num_label.string = `${data.killCount} / ${data.count}`;
  27. //敌人名字
  28. this.enemy_name_label.string = data.name_lang;
  29. }
  30. }