Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cocos2d-x 3.x on Windows: How do I change the size of my game window?

When developing using cocos2d-x 3.x for a device, it automatically sets the GL view to fit the device. In VS2012 on windows, it creates a seemingly-arbitrarily sized window. How do I set the size of that window?

like image 576
Tom Avatar asked Jun 04 '14 04:06

Tom


1 Answers

My solution was as follows.

In AppDelegate.cpp:

bool AppDelegate::applicationDidFinishLaunching() {
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) { 
        glview = GLView::create("My Game");
        glview->setFrameSize(800, 600);     // or whatever
        director->setOpenGLView(glview);
    }
    ...
}

In my particular use case, I'm setting the window sizes to various resolutions and aspect ratios to test my layouts. I'm sharing Q&A format because I couldn't find a straight answer to this anywhere.

like image 137
Tom Avatar answered Sep 30 '22 11:09

Tom