svldvw
Last Updated: February 25, 2016
·
2.108K
· kenlakoo
2a92ad89c8bd4e8b45edc8f363e18aa3 normal

Configuration of Multiple resolution in cocos2d-x 3.0

SDK in use: Cocos2d-x 3.0

Orientation: Portrait (not sure for landscape)

How to use:

  • Add the method "setupResolutionPolicy" in AppDelegate.cpp
  • Call the method inside AppDelegate::applicationDidFinishLaunching right after director->setOpenGLView(eglView);

Method: setupResolutionPolicy

void setupResolutionPolicy(float designW, float designH)
{
      Size screenSize = EGLView::getInstance()->getFrameSize();

     float designRatio = designW / designH;
     float screenRatio = screenSize.height / screenSize.width;

     ResolutionPolicy resolutionPolicy = screenRatio < designRatio ?
               ResolutionPolicy::FIXED_HEIGHT : ResolutionPolicy::FIXED_WIDTH;

    EGLView::getInstance()->setDesignResolutionSize(designW, designH, resolutionPolicy);
}
Say Thanks
Respond