iphoneX适配方式:
if(cc.sys.isNative && cc.sys.platform == cc.sys.IPHONE){
var size = cc.view.getFrameSize();
var isIphoneX = (size.width == 2436 && size.height == 1125)
||(size.width == 1125 && size.height == 2436);
if(isIphoneX){
var cvs = this.node.getComponent(cc.Canvas);
cvs.fitHeight = true;
cvs.fitWidth = true;
}
}
creator适配做的很好,以高,以宽作为适配,还是cocos2d-x以前那套,熟悉的味道。
iPad适配
let isNotFit = cc.winSize.width / cc.winSize.height <= 1.65;
let canvas = this.node.getComponent(cc.Canvas);
if (isNotFit) {
canvas.fitHeight = true;
canvas.fitWidth = true;
}
网友评论