cocos2d-x3.2 screen Adaptation

Source: Internet
Author: User

1. In the AppDelegate.cpp file

BOOL Appdelegate::applicationdidfinishlaunching () {//Initialize Director Auto Director = Director::getinstance ();    Auto Glview = Director->getopenglview ();        if (!glview) {Glview = Glview::create ("My Game");    Director->setopenglview (Glview);    } glview->setdesignresolutionsize (640, 960, Resolutionpolicy::show_all); ........................}

Setdesignresolutionsize can not be placed in the if condition, because on the Android side is not into the if condition, there is another place to do the initialization.

Parameter description:

Resolutionshowall

Stretch until the width or height reaches the screen size, but if the game's design resolution is different from the device's screen resolution ratio, the black edge will eventually appear. If you are going to fill out other sprites on the black side, it is not valid, because the black edges will not be drawn after scaling. If the design resolution is lower than the majority of the device resolution, in the case of ignoring the black edge, this adaptation can meet most of the equipment, and we later improved the adaptation scheme is to leave the black edge of the use. Conclusion: It is not possible to use black edges that do not conform to many channels and App store specifications. This parameter is understood that when we wait for the ratio of the expansion and reduction of our image resources, the first and the screen width or the height of the match will no longer stretch the other side, when the resource picture of the aspect ratio and the device's aspect ratio must have black edge.

Resolutionexactfit

Non-proportional stretching, stretching the image to the entire screen. However: If the game's design resolution and the device's screen resolution are different, the last game screen is distorted. Conclusion: can be used, but the effect is very poor.

Resolutionnoborder

Stretch until the width or height reaches the screen size and ensures that no black edges appear on the other side. is when we wait for the ratio of the expansion and reduction of our image resources, when the ratio of the small side and the edge of the device coincident, the ratio of the big side went out, so although there is no black edge, but some of the picture resources out, maybe we wrote a certain control went out.


2,framesize: In fact, the original resolution of the device (actual screen size), the development environment can be glview->setframesize () to set the resolution size of the device, of course, can also be through the glview-> Setframesize () obtains the resolution of the device;


Winsize: The first two parameters that were introduced in the Setdesignresolutionsize () method are obtained by Director::getinstance ()->getwinsize ().

Visiblesize: Must be less than or equal to winsize, that is, within the Winsize range, maintain the maximum display area of the framesize aspect ratio.

Visibleorigin: The size of the area intercepted by Framesize in Winsize, which corresponds to the lower-left corner of the screen in the design resolution.


3. Common Android Phone resolution

4:3
VGA 640*480 (Video Graphics Array)
QVGA 320*240 (Quarter VGA)
HVGA 480*320 (half-size VGA)
SVGA 800*600 (Super VGA)

5:3
WVGA 800*480 (Wide VGA)

16:9
FWVGA 854*480 (full Wide VGA)
HD 1920*1080 High Definition
QHD 960*540


720p 1280*720 SD
1080p 1920*1080 HD

Cell phone:
iphone 4/4s 960*640 (3:2)
Iphone5 1136*640
Xiaomi 1 854*480 (FWVGA)
Xiaomi 2 1280*720

Resolution corresponds to DPI
"HVGA mdpi"

"WVGA hdpi"
"FWVGA hdpi"
"QHD hdpi"
"720P xhdpi"
"1080P xxhdpi"



cocos2d-x3.2 screen Adaptation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.