[Solved] Director winsize differ in cocos2dx 3.17

[Solved] Director winsize differ in cocos2dx 3.17


Hi @slackmoehrle
I was using cocos2dx 3.14 and developing game with my iPhone6 , in that if i run
Director::getInstance()->getWinSize return actual size of device i.e Size(1136,640).

But when i am using it in cocos2dx 3.17 it return Size(960,640) .
How can i get actual size of device and could you please brief me reason of this change .



Do you have any code in your AppDelegate?

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLViewImpl::create("My Game");

    // turn on display FPS
    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0f / 60);
    // Set the design resolution
    glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::EXACT_FIT);

This is the only code which i have on applicationDidFinishLaunching
My designresolution is
designResolutionSize = cocos2d::Size(1024, 768);


Are you using the AppDelegate from 3.17? Or still using the version from 3.14?


I’m using Appdelegate from 3.17 but i have remove director->setConenteScaleFactor code from file after glview created
Below i have attached my appdelegate file AppDelegate.cpp (4.5 KB)

// Set FinalScaling Factor

AppHelper::getInstance()->setGLViewScaling(Vec2(glview->getScaleX(), glview->getScaleY()));
Here i m only setting proprty to my singleton class .

I m using my scaling method


ok, let me try some testing on my Mac.


I’m sharing what i found while debugging is = From AppConroller.mm we call
cocos2d::GLViewImpl::createWithEAGLView(( **__bridge** **void** *)_viewController.view)
this method and from that

bool GLViewImpl::initWithEAGLView( void *eaglview)

_eaglview = eaglview;

CCEAGLView *glview = (CCEAGLView*) _eaglview;

_screenSize.width = _designResolutionSize.width = [glview getWidth];

_screenSize.height = _designResolutionSize.height = [glview getHeight];

// _scaleX = _scaleY = [glview contentScaleFactor];

return true;


In this method
_screenSize.width = _designResolutionSize.width = [glview getWidth];
this line return 1136 in cocos2dx 3.14 and 960 in cocos2dx3.17

I have update my iPhone6 version to 12.0



its not the issue of version of cocos2d-x…

You have to add launch images in order to get the correct display size.


@bilalmirza darn you beat me to it. I even got up early to start work lol.


Do you feel running cocos new .. with 3.17.1 does all the right pieces for an iOS app in terms of launch images, setup, etc? Perhaps these templates are getting a bit long in the tooth?


I don’t know about now, since I’m developing for mac …but this used to be a problem for me. adding launch images used to fix this.


@bilalmirza @slackmoehrle Thanks