mirror of
https://gitee.com/dgflash/oops-framework.git
synced 2026-05-31 18:59:19 +08:00
修复动态横竖屏切换导致的游戏画面缩放异常的问题
This commit is contained in:
@@ -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
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
// }
|
||||
}
|
||||
|
||||
/** 开始热更新 */
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user