| 12345678910111213141516171819202122232425262728293031323334 |
- import { _decorator, Component, Node, Sprite, Label, ImageAsset, SpriteFrame, Texture2D } from 'cc';
- import { ResourceLoader } from '../../core/resourceManager/ResourceLoader';
- import { BitmapFont } from '../../core/ui/BitmapFont';
- import { ISJSB } from '../../data/jsb/platform';
- import { FriendData } from '../FightData';
- const { ccclass, property } = _decorator;
- /**盟友Item*/
- @ccclass('AllyItem')
- export class AllyItem extends Component {
- @property({ type: ResourceLoader, displayName: "资源加载组件", tooltip: "资源加载组件" })
- res: ResourceLoader = null;
- @property({ type: Sprite, displayName: "头像", tooltip: "头像" })
- imgHead: Sprite = null;
- @property({ type: Label, displayName: "文本昵称", tooltip: "文本昵称" })
- txtNickName: Label = null;
- @property({ type: BitmapFont, displayName: "文本贡献值", tooltip: "文本贡献值" })
- txtDevote: BitmapFont = null;
- public async onDataChange(friendData: FriendData, index: number) {
- this.txtNickName.string = friendData.nickName;
- this.txtDevote.string = `${friendData.contribution}`; //具体值从神台 列表数据中获取
- if (ISJSB() && friendData.avator) {
- let img = await this.res.loadRemote<ImageAsset>(friendData.avator, { ext: ".png" });
- const spriteFrame = new SpriteFrame();
- const texture = new Texture2D();
- texture.image = img;
- spriteFrame.texture = texture;
- this.imgHead.spriteFrame = spriteFrame;
- }
- }
- }
|