按 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;
}