Cocostudio: scene size?

I have created a scene in cocostudio with design size set to 480x320. I positioned all elements pins and percentage, so them should adopt well for different resolutions.

I load the scene using next code:

auto scene = Scene::create();
Node *node = CSLoader::getInstance()->createNode(R::UI::MAIN_MENU_SCENE);
scene->addChild(node);

What are the problems:

  • if aspect ratio of the device isn’t 3:2 (iphone 5 +) then the scene not resized. Just empty space added to the right (or if design resolution size not set to 480x320);
  • ttf labels just scaled up, so them looks blurry;

Can these issues be solved in cocostudio?

Used cocostudio 2.2.1, cocos2dx 3.5, macos

Is it expected behaviour of cocostudio? It looks almost useless then.

Did you find a solution for your issue? I am just starting to port my portrait 1920 x 1080 game to ipad and am not completely sure where to start.

I found some solution to get expected behaviour, but i believe it should be provided by the CSLoader itself.

namespace GuiUtils {
    void iterateRecursively(Node *parent, std::function<void(Node *)>callback) {
        callback(parent);
    
        auto &children = parent->getChildren();
        for (auto child : children) {
            iterateRecursively(child, callback);
        }
    }
}

void HelloWorld::initialize(cocos2d::Scene *scene) {
    _rootNode = CSLoader::createNode("MainScene.csb");
    scene->addChild(_rootNode);
    
    //update size of the root node to win size
    {
        LayoutComponent *layout = LayoutComponent::bindLayoutComponent(_rootNode);
        auto size = Director::getInstance()->getWinSize();
        layout->setSize(size);
    }
    
    //manually refresh layout for all children
    GuiUtils::iterateRecursively(_rootNode, [](Node *child) {
        LayoutComponent *layout = LayoutComponent::bindLayoutComponent(child);
        layout->refreshLayout();
    });
}

P.S. All samples that i found also wasn’t adapted for multi resolution support and just use ResolutionPolicy::EXACT_FIT, and there no any discuss about this problem… I couldn’t believe that it’s an expected behaviour.

Here is a solution: