Skip to content

Instantly share code, notes, and snippets.

@tklee1975
Last active August 29, 2015 14:01
Show Gist options
  • Save tklee1975/d6cca60bf94a6ddc4088 to your computer and use it in GitHub Desktop.
Save tklee1975/d6cca60bf94a6ddc4088 to your computer and use it in GitHub Desktop.
Setup Multiple Resolution in cocos2d-x 3.0
void setupResolutionPolicy(float designW, float designH)
{
GLView *view = Director::getInstance()->getOpenGLView();
Size screenSize = view->getFrameSize();
float designRatio = designW / designH;
float screenRatio = screenSize.height / screenSize.width;
ResolutionPolicy resolutionPolicy = screenRatio < designRatio ?
ResolutionPolicy::FIXED_HEIGHT : ResolutionPolicy::FIXED_WIDTH;
view->setDesignResolutionSize(designW, designH, resolutionPolicy);
}
@tklee1975
Copy link
Author

Place the above method inside AppDelegate.cpp;
And call it inside applicationDidFinishLaunching after the statement " auto glview = director->getOpenGLView();"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment