Commit 9194fbdb authored by 范雪寒's avatar 范雪寒

feat:

parent 396d96dd
......@@ -5,6 +5,7 @@ import { initResMgr_NGT_02 } from "../manager/res_mgr";
import { initSndMgr_NGT_02 } from "../manager/snd_mgr";
import { initUtils_NGT_02 } from "./utils";
import { initEnumMgr_NGT_02 } from "../game/speaker";
// 全局环境预声明
export function initGlobal_NGT_02() {
console.log('window.g init');
......
import { initGlobal_NGT_02 } from "./_preDefine";
/**
* 适配
*/
......@@ -8,7 +9,7 @@ cc.Class({
UIMax: {
default: [],
type: cc.Node,
displayName: "等比放大"
displayName: "等比放大",
},
topUI: {
default: [],
......@@ -18,26 +19,29 @@ cc.Class({
bgScaleMax: {
default: [],
type: cc.Node,
displayName: "背景适配"
displayName: "背景适配",
},
nodeUIOffset: {
default: [],
type: cc.Node,
displayName: "节点偏移"
displayName: "节点偏移",
},
canvasView: {
default: null,
type: cc.Canvas,
displayName: "根节点"
displayName: "根节点",
},
isCanvas: {
default: false,
}
},
},
onLoad: function () { //开启适配
onLoad: function () {
initGlobal_NGT_02();
//开启适配
this.widgetList = [];
this.scheduleOnce(function () {
......@@ -45,8 +49,8 @@ cc.Class({
this.init();
} else {
var canvaSize = this.findCanvas();
var w = (canvaSize.width) / 720;
var h = (canvaSize.height) / 1280;
var w = canvaSize.width / 720;
var h = canvaSize.height / 1280;
this.MaxSize = w / h > 1 ? w / h : h / w;
this.setUIMax(this.MaxSize);
......@@ -55,7 +59,7 @@ cc.Class({
this.setUiPositon();
var scene = cc.director.getScene();
var list = scene.getComponentsInChildren(cc.Widget)
var list = scene.getComponentsInChildren(cc.Widget);
for (var i in list) {
list[i].updateAlignment();
}
......@@ -85,8 +89,8 @@ cc.Class({
this.canvasView.fitWidth = true;
this.canvasView.fitHeight = true;
}
var w = (canvaSize.width) / 750;
var h = (canvaSize.height) / 1334;
var w = canvaSize.width / 750;
var h = canvaSize.height / 1334;
this.MaxSize = w / h > 1 ? w / h : h / w;
g.data_mgr.MaxSize = this.MaxSize;
......@@ -95,7 +99,7 @@ cc.Class({
this.setBgScale();
this.setUiPositon();
var scene = cc.director.getScene();
var list = scene.getComponentsInChildren(cc.Widget)
var list = scene.getComponentsInChildren(cc.Widget);
for (var i in list) {
list[i].updateAlignment();
}
......@@ -115,7 +119,6 @@ cc.Class({
for (var i in this.topUI) {
if (this.topUI[i].perTop == undefined) {
this.topUI[i].perTop = this.topUI[i].top;
} else {
this.topUI[i].top = this.topUI[i].perTop;
}
......@@ -155,8 +158,10 @@ cc.Class({
let realHeight = 720 * srcScaleForShowAll;
// 2. 基于第一步的数据,再做节点宽高重置
this.nodeUIOffset[i].width = 1280 * (cc.view.getCanvasSize().width / realWidth);
this.nodeUIOffset[i].height = 720 * (cc.view.getCanvasSize().height / realHeight);
this.nodeUIOffset[i].width =
1280 * (cc.view.getCanvasSize().width / realWidth);
this.nodeUIOffset[i].height =
720 * (cc.view.getCanvasSize().height / realHeight);
}
},
......@@ -164,7 +169,6 @@ cc.Class({
for (var i in this.UIMax) {
if (this.UIMax[i].perScale == undefined) {
this.UIMax[i].perScale = this.UIMax[i].scaleX;
} else {
this.UIMax[i].scaleX = this.UIMax[i].perScale;
this.UIMax[i].scaleY = this.UIMax[i].perScale;
......@@ -177,13 +181,13 @@ cc.Class({
if (cc.sys.isNative) {
return {
width: cc.view.getFrameSize().width,
height: cc.view.getFrameSize().height
height: cc.view.getFrameSize().height,
};
} else {
return {
width: cc.game.canvas.clientWidth,
height: cc.game.canvas.clientHeight
height: cc.game.canvas.clientHeight,
};
}
}
},
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment