按 cc.ResolutionPolicy.SHOW_ALL 适配,只需要在左侧显示位置的时候,设置一下偏移量
var appleMobileType = {
"iPhone XS Max": cc.size(2688, 1242),
"iPhone X/XS": cc.size(2436, 1125),
"iPhone XR": cc.size(1792, 828),
}
// 苹果设备 刘海屏 设置偏移量
var calcDelayX = {
"iPhone XS Max": 60,
"iPhone X/XS": 50,
"iPhone XR": 60,
}
// 获取苹果手机刘海屏机型 偏移量
var getAppleMobileDelayX = function() {
// 首先判断是否是苹果手机
if (cc.sys.os == cc.sys.OS_IOS) {
var size = cc.view.getFrameSize();
for (var key in appleMobileType) {
if (appleMobileType[key].width == size.width && appleMobileType[key].height == size.height) {
return calcDelayX[key];
}
}
}
return 0;
}