cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.25k stars 7.06k forks source link

Fixed bug size does not change when the screen is rotated in v4 #20662

Closed nk-5 closed 3 years ago

nk-5 commented 3 years ago

in forum discuss

https://discuss.cocos2d-x.org/t/in-cocos2dx-v4-0-the-screen-becomes-half-size-when-you-change-the-device-from-portrait-to-landscape/51631

background

Cause of the problem

It turns out that the cause of the problem is that the layer of CCEAGLView is CAMetalLayer, and CAMetalLayer.drawableSize is not updated when CCEAGLView.layoutSubView is used.

Revision details

Fixed to resize CAMetalLayer on CCEAGLView layoutSubviews.

related issues

nk-5 commented 3 years ago

@minggo I would appreciate it if you could confirm this pr.

minggo commented 3 years ago

How to change the size? From portrait to landscape?

nk-5 commented 3 years ago

How to change the size? From portrait to landscape?

@minggo The size of the layer changes when the screen is rotated, assuming that the application has been implemented to support portrait and landscape. Specifically, we call the setFrameSize and setDesignResolutionSize api of GLView to change the size when the screen is rotated.

minggo commented 3 years ago

Got it, thanks.