I’ve seen this accomplished in Geometry Sprint (which can also be programmed with Cocos2d-x c++) and I need to know the way to:
A) Scale each aspect in accordance with the window measurement
B) Preserve facet ratio when resizing window
C) Refresh measurement and place of every aspect when window measurement is altered
D) Permit switching to full display screen in-game
I’m very new to cocos2dx and c++, so I figured I might cease right here to attempt to determine this all out.
Thanks to anybody who helps!!
In AppDelegate.cpp, discover the applicationDidFinishLaunching() operate:
bool AppDelegate::applicationDidFinishLaunching() {
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLViewImpl::createWithRect("MyGame", cocos2d::Rect(0,0,960,640)); // Preliminary window measurement
director->setOpenGLView(glview);
}
// Set the Design Decision Measurement
// That is the display screen measurement you used to design your sport.
// Instance: You designed your sport on a 960x640 display screen
director->getOpenGLView()->setDesignResolutionSize(960, 640, ResolutionPolicy::SHOW_ALL);
// ... (different settings)
return true;
}
Within the instance above, I used ResolutionPolicy::SHOW_ALL. You possibly can attempt different insurance policies to see which one most accurately fits your sport.
Thanks, Patterson. That rationalization helps make clear how the design decision works. Simply to substantiate, if I need UI components to reposition appropriately when resizing the window, ought to I manually replace their positions within the onResize occasion, or is there a built-in method to deal with that?

