美术更新
- detail页面修改 - ui布局修改
This commit is contained in:
@@ -1,58 +1,111 @@
|
||||
import { _decorator, Component, Node,Sprite ,UITransform} from 'cc';
|
||||
import {
|
||||
_decorator,
|
||||
Component,
|
||||
Node,
|
||||
Sprite,
|
||||
UITransform,
|
||||
VideoPlayer,
|
||||
view,
|
||||
} from "cc";
|
||||
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
||||
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import {ViewManager} from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
import {GButton} from "db://assets/Scripts/Main/Common/GButton";
|
||||
import { ViewManager } from "db://assets/Scripts/Main/Manager/ViewManager";
|
||||
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
interface ShowPanelData
|
||||
{
|
||||
url: string;
|
||||
closeFunc:Function;
|
||||
interface ShowPanelData {
|
||||
url: string;
|
||||
isImg: boolean;
|
||||
closeFunc: Function;
|
||||
}
|
||||
|
||||
@ccclass('ShowPanel')
|
||||
@ccclass("ShowPanel")
|
||||
export class ShowPanel extends li_BaseView {
|
||||
@property(Sprite)
|
||||
image:Sprite;
|
||||
@property(Sprite)
|
||||
splash:Sprite;
|
||||
@property(Sprite)
|
||||
image: Sprite;
|
||||
@property(Sprite)
|
||||
splash: Sprite;
|
||||
@property(VideoPlayer)
|
||||
videoPlayer: VideoPlayer;
|
||||
|
||||
url:string;
|
||||
func:Function;
|
||||
openUIDataCT(data:ShowPanelData) {
|
||||
super.openUIDataCT(data);
|
||||
this.url = data.url;
|
||||
this.func = data.closeFunc;
|
||||
url: string;
|
||||
func: Function;
|
||||
isImg: boolean;
|
||||
openUIDataCT(data: ShowPanelData) {
|
||||
super.openUIDataCT(data);
|
||||
this.url = data.url;
|
||||
this.isImg = data.isImg;
|
||||
this.func = data.closeFunc;
|
||||
}
|
||||
|
||||
onLoadCT() {
|
||||
this.show(this.url);
|
||||
|
||||
// 添加视频加载完成回调
|
||||
this.videoPlayer.node.on(
|
||||
VideoPlayer.EventType.READY_TO_PLAY,
|
||||
() => {
|
||||
this.adjustVideoScale();
|
||||
},
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
start() {
|
||||
//this.splash.node.on(Node.EventType.TOUCH_START,this.onclickback);
|
||||
GButton.BandClick(this.splash.node, this.onClose, this);
|
||||
}
|
||||
|
||||
protected onClose() {
|
||||
if (this.func) {
|
||||
this.func();
|
||||
}
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
show(path: string) {
|
||||
if (this.isImg) {
|
||||
ResManager.I.changeBundleSpriteFrame(this.image, path, "Chat18x", () => {
|
||||
Utils.adjustBgPixelRatio(this.image.node, 3);
|
||||
});
|
||||
} else {
|
||||
ResManager.I.changeBundleVideo(this.videoPlayer, path, "Chat18x", () => {
|
||||
this.adjustVideoScale();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
adjustVideoScale() {
|
||||
if (!this.videoPlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
onLoadCT() {
|
||||
this.show(this.url);
|
||||
const tryAdjustScale = () => {
|
||||
const screenSize = view.getVisibleSize();
|
||||
|
||||
}
|
||||
const videoTransform = this.videoPlayer.node.getComponent(UITransform);
|
||||
|
||||
start()
|
||||
{
|
||||
//this.splash.node.on(Node.EventType.TOUCH_START,this.onclickback);
|
||||
GButton.BandClick(this.splash.node,this.onClose,this);
|
||||
}
|
||||
if (videoTransform && videoTransform.height > 0) {
|
||||
let scale = screenSize.width / videoTransform.width;
|
||||
this.videoPlayer.node.setScale(scale, scale, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
protected onClose() {
|
||||
if(this.func)
|
||||
{
|
||||
this.func();
|
||||
// 立即尝试一次
|
||||
if (!tryAdjustScale()) {
|
||||
// 如果失败,延迟尝试
|
||||
this.scheduleOnce(() => {
|
||||
if (!tryAdjustScale()) {
|
||||
// 再次延迟尝试
|
||||
this.scheduleOnce(() => {
|
||||
tryAdjustScale();
|
||||
}, 0.5);
|
||||
}
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
show(path:string)
|
||||
{
|
||||
ResManager.I.changeBundleSpriteFrame(this.image,path,"Chat18x",()=>{
|
||||
Utils.adjustBgPixelRatio(this.image.node,3);
|
||||
});
|
||||
}, 0.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user