LayerManager添加窗口宽高比例与设计宽高比例属性

This commit is contained in:
dgflash
2024-11-07 11:34:58 +08:00
parent 55ca68c968
commit c2049b6778

View File

@@ -82,6 +82,11 @@ export class LayerManager {
/** 新手引导层 */
guide!: Node;
/** 窗口宽高比例 */
windowAspectRatio: number = 0;
/** 设计宽高比例 */
designAspectRatio: number = 0;
/** 界面层 */
private readonly ui!: LayerUI;
/** 弹窗层 */
@@ -98,13 +103,13 @@ export class LayerManager {
private initScreenAdapter() {
const drs = view.getDesignResolutionSize();
const ws = screen.windowSize;
const windowAspectRatio = ws.width / ws.height;
const designAspectRatio = drs.width / drs.height;
this.windowAspectRatio = ws.width / ws.height;
this.designAspectRatio = drs.width / drs.height;
let finalW: number = 0;
let finalH: number = 0;
if (windowAspectRatio > designAspectRatio) {
if (this.windowAspectRatio > this.designAspectRatio) {
finalH = drs.height;
finalW = finalH * ws.width / ws.height;
oops.log.logView("适配屏幕高度", "【横屏】");