| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import { _decorator, Component, Node, Size, Sprite, SpriteFrame, UITransform } from 'cc';
- import { Hall } from '../../hall/Hall';
- import { ch } from 'db://assets/ch/ch';
- const { ccclass, property } = _decorator;
- @ccclass('UI_Head_Icon')
- export class UI_Head_Icon extends Component {
- @property(Sprite)//头像
- Headicon: Sprite = null;
- @property([SpriteFrame])
- Head_Skin: SpriteFrame[] = [];
-
- show(uid: string, head: string | null): void {
-
-
- const rc = this.Head_Skin[ parseInt(uid)%4];
- Hall.getInstance().head_icon.showIcon(uid, head, this.Headicon, rc).then((spf)=>{
- if(spf != null)
- this.adaptationIcon(this.Headicon, spf, new Size(57,57));
- });
-
- }
- adaptationIcon(icon: Sprite, spriteFrameIcon: SpriteFrame, tSize: Size) {
- if (spriteFrameIcon) {
- let size = spriteFrameIcon.originalSize
- //适配图片
- let iconSize = new Size()
- let raito = size.width / size.height
- if (raito < 1) {
- iconSize.height = tSize.height
- iconSize.width = tSize.height * raito
- } else {
- iconSize.width = tSize.width
- iconSize.height = tSize.width / raito
- }
- icon.spriteFrame = spriteFrameIcon
- icon.getComponent(UITransform).setContentSize(iconSize)
- }
- }
- }
|