From ffedad7185945b65ddd767ebebde2339431ed310 Mon Sep 17 00:00:00 2001 From: dgflash Date: Mon, 9 May 2022 19:36:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=A8=E6=80=81=E6=A8=AA?= =?UTF-8?q?=E7=AB=96=E5=B1=8F=E5=88=87=E6=8D=A2=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E7=94=BB=E9=9D=A2=E7=BC=A9=E6=94=BE=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/main.scene | 8 ++-- assets/script/core/gui/GUI.ts | 38 +++++++++++++++---- .../script/game/initialize/view/HotUpdate.ts | 12 +++--- .../game/initialize/view/LoadingViewComp.ts | 6 +-- 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/assets/main.scene b/assets/main.scene index e61fa62..77098de 100644 --- a/assets/main.scene +++ b/assets/main.scene @@ -32,7 +32,7 @@ { "__type__": "cc.Node", "_name": "root", - "_objFlags": 0, + "_objFlags": 512, "_parent": { "__id__": 1 }, @@ -82,7 +82,7 @@ { "__type__": "cc.Node", "_name": "game", - "_objFlags": 0, + "_objFlags": 512, "_parent": { "__id__": 2 }, @@ -121,7 +121,7 @@ { "__type__": "cc.Node", "_name": "gui", - "_objFlags": 0, + "_objFlags": 512, "_parent": { "__id__": 2 }, @@ -174,7 +174,7 @@ { "__type__": "cc.Node", "_name": "UICamera", - "_objFlags": 0, + "_objFlags": 512, "_parent": { "__id__": 4 }, diff --git a/assets/script/core/gui/GUI.ts b/assets/script/core/gui/GUI.ts index 7203ac9..82033dd 100644 --- a/assets/script/core/gui/GUI.ts +++ b/assets/script/core/gui/GUI.ts @@ -2,9 +2,9 @@ * @Author: dgflash * @Date: 2021-07-03 16:13:17 * @LastEditors: dgflash - * @LastEditTime: 2022-01-27 11:25:15 + * @LastEditTime: 2022-05-09 19:34:22 */ -import { Camera, Component, ResolutionPolicy, screen, UITransform, view, _decorator } from "cc"; +import { Camera, Component, math, ResolutionPolicy, screen, UITransform, view, _decorator } from "cc"; import { Logger } from "../common/log/Logger"; const { ccclass, menu } = _decorator; @@ -13,11 +13,16 @@ const { ccclass, menu } = _decorator; @ccclass('GUI') export class GUI extends Component { /** 界面层矩形信息组件 */ - public transform!: UITransform; + transform!: UITransform; /** 游戏二维摄像机 */ - public camera!: Camera; + camera!: Camera; /** 是否为竖屏显示 */ - public portrait!: boolean; + portrait!: boolean; + + /** 竖屏设计尺寸 */ + private portraitDrz: math.Size = null!; + /** 横屏设计尺寸 */ + private landscapeDrz: math.Size = null!; onLoad() { this.init(); @@ -27,12 +32,29 @@ export class GUI extends Component { protected init() { this.transform = this.getComponent(UITransform)!; this.camera = this.getComponentInChildren(Camera)!; + + if (view.getDesignResolutionSize().width > view.getDesignResolutionSize().height) { + this.landscapeDrz = view.getDesignResolutionSize(); + this.portraitDrz = new math.Size(this.landscapeDrz.height, this.landscapeDrz.width); + } + else { + this.portraitDrz = view.getDesignResolutionSize(); + this.landscapeDrz = new math.Size(this.portraitDrz.height, this.portraitDrz.width); + } + this.resize(); } - public resize() { - let dr = view.getDesignResolutionSize(); - var s = screen.windowSize; + resize() { + let dr; + if (view.getDesignResolutionSize().width > view.getDesignResolutionSize().height) { + dr = this.landscapeDrz; + } + else { + dr = this.portraitDrz + } + + var s = screen.windowSize; var rw = s.width; var rh = s.height; var finalW = rw; diff --git a/assets/script/game/initialize/view/HotUpdate.ts b/assets/script/game/initialize/view/HotUpdate.ts index a26c0b8..4f4f759 100644 --- a/assets/script/game/initialize/view/HotUpdate.ts +++ b/assets/script/game/initialize/view/HotUpdate.ts @@ -2,7 +2,7 @@ * @Author: dgflash * @Date: 2022-04-15 14:44:04 * @LastEditors: dgflash - * @LastEditTime: 2022-04-15 20:25:02 + * @LastEditTime: 2022-05-09 18:32:44 */ import { Component, game, sys, _decorator } from "cc"; import { tips } from "../../../core/gui/prompt/TipsManager"; @@ -22,11 +22,11 @@ export class HotUpdate extends Component { private lv: LoadingViewComp = null!; onLoad() { - if (sys.isNative) { - this.lv = this.getComponent(LoadingViewComp)!; - this.lv.data.prompt = oops.language.getLangByID("update_tips_check_update"); - this.startHotUpdate(); - } + // if (sys.isNative) { + // this.lv = this.getComponent(LoadingViewComp)!; + // this.lv.data.prompt = oops.language.getLangByID("update_tips_check_update"); + // this.startHotUpdate(); + // } } /** 开始热更新 */ diff --git a/assets/script/game/initialize/view/LoadingViewComp.ts b/assets/script/game/initialize/view/LoadingViewComp.ts index 6a931a1..e96e7f7 100644 --- a/assets/script/game/initialize/view/LoadingViewComp.ts +++ b/assets/script/game/initialize/view/LoadingViewComp.ts @@ -2,7 +2,7 @@ * @Author: dgflash * @Date: 2021-07-03 16:13:17 * @LastEditors: dgflash - * @LastEditTime: 2022-04-15 20:12:33 + * @LastEditTime: 2022-05-09 18:34:16 */ import { sys, _decorator } from "cc"; import { resLoader } from "../../../core/common/loader/ResLoader"; @@ -52,9 +52,9 @@ export class LoadingViewComp extends CCVMParentComp { } start() { - if (!sys.isNative) { + // if (!sys.isNative) { this.enter(); - } + // } } enter() {