using landscape layout to device initialization

This commit is contained in:
jerrywwl
2019-04-03 15:56:07 +08:00
parent b093131f94
commit bde3872f68
2 changed files with 19 additions and 4 deletions
+14 -2
View File
@@ -699,8 +699,20 @@ class Game extends EventTarget {
this._gfxDevice = new cc.WebGLGFXDevice();
}
const nativeWidth = Math.floor(screen.width * window.devicePixelRatio);
const nativeHeight = Math.floor(screen.height * window.devicePixelRatio);
cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
cc.view._initFrameSize();
let nativeWidth = Math.floor(screen.width * window.devicePixelRatio);
let nativeHeight = Math.floor(screen.height * window.devicePixelRatio);
if (nativeHeight > nativeWidth) {
let temp = localCanvas.width;
localCanvas.width = localCanvas.height;
localCanvas.height = temp;
temp = nativeWidth;
nativeWidth = nativeHeight;
nativeHeight = temp;
}
this._gfxDevice.initialize({
canvasElm: localCanvas,
+5 -2
View File
@@ -1097,12 +1097,15 @@ class ContainerStrategy {
locContainer.style.height = locCanvas.style.height = h + 'px';
}
// Setup pixel ratio for retina display
/*
var devicePixelRatio = view._devicePixelRatio = 1;
if (view.isRetinaEnabled())
devicePixelRatio = view._devicePixelRatio = Math.min(2, window.devicePixelRatio || 1);
// Setup canvas
// locCanvas.width = w * devicePixelRatio;
// locCanvas.height = h * devicePixelRatio;
locCanvas.width = w * devicePixelRatio;
locCanvas.height = h * devicePixelRatio;
*/
locCanvas.width = w;
locCanvas.height = h;