kingBook

导航

getVisibleSize,getWinSize,getFrameSize,getViewPortRect

cc.director.getVisibleSize();//获取运行场景的可见大小
cc.director.getWinSize();//获取视图的大小,以点为单位
cc.director.getWinSizeInPixels();//获取视图大小,以像素为单位
cc.view.getFrameSize();//Returns the frame size of the view.
cc.view.getViewPortRect();//Returns the view port rectangle.
cc.view.getVisibleSize();//Returns the visible area size of the view port.
cc.view.getVisibleSizeInPixel();//Returns the visible area size of the view port.
cc.view.getDesignResolutionSize();//Returns the designed size for the view. Default resolution size is the same as 'getFrameSize'.

使用以下代码在chrome中测试得出结果

log("cc.director.getVisibleSize:",cc.director.getVisibleSize().toString());
cc.log("cc.director.getWinSize:",cc.director.getWinSize().toString());
cc.log("cc.director.getWinSizeInPixels:",cc.director.getWinSizeInPixels().toString());
cc.log("cc.view.getFrameSize:",cc.view.getFrameSize().toString());
cc.log("cc.view.getViewPortRect:",cc.view.getViewPortRect().toString());
cc.log("cc.view.getVisibleSize:",cc.view.getVisibleSize().toString());
cc.log("cc.view.getVisibleSizeInPixel:",cc.view.getVisibleSizeInPixel().toString());
cc.log("cc.view.getDesignResolutionSize:",cc.view.getDesignResolutionSize().toString());
=============Default=============
cc.director.getVisibleSize:      (480.00, 800.00)
cc.director.getWinSize:          (480.00, 800.00)
cc.director.getWinSizeInPixels:  (480.00, 800.00)
cc.view.getFrameSize:            (480.00, 800.00)
cc.view.getViewPortRect:         (0.00, 0.00, 480.00, 800.00)
cc.view.getVisibleSize:          (480.00, 800.00)
cc.view.getVisibleSizeInPixel:   (480.00, 800.00)
cc.view.getDesignResolutionSize: (480.00, 800.00)
截图工具测量大小:                  (480.00, 800.00)
=============Iphone4=============
cc.director.getVisibleSize:      (533.33, 800.00)
cc.director.getWinSize:          (533.33, 800.00)
cc.director.getWinSizeInPixels:  (533.33, 800.00)
cc.view.getFrameSize:            (320.00, 480.00)
cc.view.getViewPortRect:         (0.00, 0.00, 320.00, 480.00)
cc.view.getVisibleSize:          (533.33, 800.00)
cc.view.getVisibleSizeInPixel:   (320.00, 480.00)
cc.view.getDesignResolutionSize: (480.00, 800.00)
截图工具测量大小:                  (320.00, 480.00)
=============Iphone6 Plus=============
cc.director.getVisibleSize:      (450.00, 800.00)
cc.director.getWinSize:          (450.00, 800.00)
cc.director.getWinSizeInPixels:  (450.00, 800.00)
cc.view.getFrameSize:            (414.00, 736.00)
cc.view.getViewPortRect:         (0.00, 0.00, 414.00, 736.00)
cc.view.getVisibleSize:          (450.00, 800.00)
cc.view.getVisibleSizeInPixel:   (414.00, 736.00)
cc.view.getDesignResolutionSize: (480.00, 800.00)
截图工具测量大小:                  (414.00, 736.00)

1.cc.director.getVisibleSize();//获取运行场景的可见大小
不理解,它和我用截图工具测量的不一样啊??
2.cc.director.getWinSize();//获取视图的大小,以点为单位
cc.director.getWinSizeInPixels();//获取视图大小,以像素为单位
不理解,它们两个数值都一样啊,你这里的视图大小指的什么????
3.cc.view.getFrameSize();//Returns the frame size of the view
不理解,????
4.cc.view.getViewPortRect();//Returns the view port rectangle.
不理解,????
5.cc.view.getVisibleSize();//Returns the visible area size of the view port.
cc.view.getVisibleSizeInPixel();//Returns the visible area size of the view port.
了解,也只有这一个和截图大小一致,两VisibleSize与VisibleSizeInPixel这两个不一样,单位不同
**6.cc.view.getDesignResolutionSize();//Returns the designed size for the view. Default resolution size is the same as 'getFrameSize'.
了解,和场景中Canvas设置的一样

cc.director.getVisibleSize(),其实就是运行场景实际显示的大小,但它并不计算可视区域大小的缩放值,是根据设计分辨率未缩放的原始比例(1:1)计算出结果,所以可以用他来计算出,显示区域与设计分辨的缩放比例

frameSize: 指的就是设备的分辨率尺寸,用截图工具测量多大就是多大

posted on 2018-03-20 18:05  kingBook  阅读(779)  评论(0编辑  收藏  举报