Skip to content

Commit 2a4159f

Browse files
committed
Merge pull request cocos2d#2213 from VisualSJ/5888
Issue #5888: Type resolution adaptation
2 parents 94ee797 + 01e990b commit 2a4159f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

cocos2d/core/platform/CCEGLView.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,20 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
174174

175175
_initFrameSize: function () {
176176
var locFrameSize = this._frameSize;
177-
locFrameSize.width = this._frame.clientWidth;
178-
locFrameSize.height = this._frame.clientHeight;
177+
//To get the most likely for the actual display resolution data
178+
var sWidth = Math.min(window.screen.availWidth, window.screen.width) * window.devicePixelRatio;
179+
var sHeight = Math.min(window.screen.availHeight, window.screen.height) * window.devicePixelRatio;
180+
//Calibration of the actual resolution may be smaller
181+
if(cc.sys.isMobile && this._frame.clientWidth >= sWidth * 0.8){
182+
locFrameSize.width = sWidth / window.devicePixelRatio;
183+
}else{
184+
locFrameSize.width = this._frame.clientWidth;
185+
}
186+
if(cc.sys.isMobile && this._frame.clientWidth >= sHeight * 0.8){
187+
locFrameSize.height = sHeight / window.devicePixelRatio;
188+
}else{
189+
locFrameSize.height = this._frame.clientHeight;
190+
}
179191
},
180192

181193
// hack
@@ -188,7 +200,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
188200

189201
_setViewPortMeta: function (width, height) {
190202
if (this._isAdjustViewPort) {
191-
var viewportMetas = {"user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0"}, elems = document.getElementsByName("viewport"), vp, content;
203+
var viewportMetas = {"user-scalable": "no", "maximum-scale": "1.0", "initial-scale": "1.0", width: "device-width"},
204+
elems = document.getElementsByName("viewport"), vp, content;
192205
if (elems.length == 0) {
193206
vp = cc.newElement("meta");
194207
vp.name = "viewport";

0 commit comments

Comments
 (0)