CocosCreator屏幕适配

官方文档已经讲解的非常详细明了。

Cocos Creator教程:屏幕适配

Cocos Creator屏幕适配

iphoneX适配
Cocos2D-X屏幕适配新解

      //---->设计分辨率
      let size0: cc.Size = cc.view.getDesignResolutionSize();
      console.log("width 0:" + size0.width + ", height 0:" + size0.height);

      //---->可视区域大小
      let size1: cc.Size = cc.view.getVisibleSize();
      console.log("width 1:" + size1.width+", height 1:" + size1.height);
      
      let size2: cc.Size = cc.winSize;
      console.log("width 2:" + size2.width+", height 2:" + size2.height);
    
      let size3: cc.Size = cc.view.getVisibleSizeInPixel();
      console.log("width 3:" + size3.width+", height 3:" + size3.height);
 
      //---->屏幕物理分辨率 也就是手机分辨率。
      let size4: cc.Size = cc.view.getFrameSize();
      console.log("width 4:" + size4.width+", height 4:" + size4.height); 

你可能感兴趣的:(CocosCreator)