import { _decorator, Component, Node, Size, Sprite, SpriteFrame, UITransform } from 'cc'; import { base_ui } from '../fw/base_ui'; import { tools } from '../tools'; const { ccclass, property } = _decorator; @ccclass('gameplay_view') export class gameplay_view extends base_ui { @property(Node) btn_close:Node = null @property(Node) content_img:Node = null protected start(): void { this.onButtonListen(this.btn_close, ()=>{ this.close() }) let img_url = tools.sys_config.game_introduction_img // console.log('img_url=',img_url) if(img_url.length>0) { tools.loadRemoteImg(img_url, (r)=>{ this.showContentImg(r.sf) }) } } private showContentImg(sf:SpriteFrame) { if(sf==null||sf==undefined) { return } let img_width = this.content_img.getComponent(UITransform).contentSize.width let bili = sf.width / sf.height let img_height = img_width / bili let img_size = new Size(img_width, img_height) this.content_img.getComponent(UITransform).setContentSize(img_size) this.content_img.getComponent(Sprite).spriteFrame = sf } }