Cocos2d-x basics

Some articles about Cocos2d-x framework

Screen size

Posted at — Sep 25, 2020

We have already learned now to add objects to the screen and how to do some things with them; that’s enough for a simple games. But there is one more thing left unexplained about our default program and this is the screen size.

Our first program

The default program creates a window 480x320 pixels size. This value was specified in AppDelegate.cpp by following statement:

static cocos2d::Size designResolutionSize = cocos2d::Size(480, 320);

The cocos2d-x developers over-engineered the default example, so you’ll see some attempts to use another screen resolutions in that file. That’s a known bug actually. That part of code never works and really you can delete it like here.

It’s too complicated to handle different screen sizes correctly, especially on mobile devices. There will be another post about this later. For now, you should know two things: