我给出部分代码吧
export class UICfg {
public static get SCR_DESIZE_SIZE() {
return cc.size(1366, 768);
}
public static get SCR_SIZE() {
return cc.view.getVisibleSize();
}
public static get SCR_W() {
return cc.view.getVisibleSize().width;
}
public static get SCR_CW() {
return cc.view.getVisibleSize().width / 2;
}
public static get SCR_H() {
return cc.view.getVisibleSize().height;
}
public static get SCR_CH() {
return cc.view.getVisibleSize().height / 2;
}
public static get SCR_EDGE() {
return Math.max(0, UICfg.SCR_CW - 768);
}
}
if(cc.view.getVisibleSize().width == 0 || cc.view.getVisibleSize().height == 0) {
if(CC_DEV) {
cc.assert(false, "fatal error");
}
}
因为其它的地方, 有常量初始化的时候会间接调用到cc.view.getVisibleSize