Positioning in Cocos Studio

Hello,
I wanted use cocos studio in our existing game for desigh UI elements and effects setup.

I created simple scene with one button in the center of display. Export csb file and load it the game with

auto rootNode = CSLoader::createNode("MainScene.csb");
addChild(rootNode, 10);

The button is placed completely wrong. The weird think is that position depends on view in Studio. When I choose 480x320 it is nearly in the center but when I use for example 1024x768 it is wrong in the corner.
How can be position dependent on view type?

I looked into code where position is loaded and the position is just set to the sprite but there is no computation based on current scale / display size etc. And that position is different when I change the view on different resolution…

How can I setup sprite position correctly?

Thanks for hint.

Cheers,
Jiri

I too have faced the same problem.

Partially worked out for me.

visibleSize = Director::getInstance()->getVisibleSize();
frameSize = Director::getInstance()->getOpenGLView()->getFrameSize();

auto rootNode = CSLoader::createNode("MainScene.csb");
addChild(rootNode);

sz = rootNode->getContentSize();
x1 = visibleSize.width/sz.width;
y1 = visibleSize.height/sz.height;

posParam = (x1+y1)/2;

Now scale everything present inside root node and update the positions of everything based on the scale factor.

auto bee = rootNode->getChildren();

for (int i =0; i<bee.size(); i++) {
    
    spr = (Sprite*)bee.at(i);
    str1 = __String::create(spr->getName());
    str1 = (__String*)str1->componentsSeparatedByString("_")->getObjectAtIndex(0);
    spr->setName(str1->getCString());
    spr->setScale(x1, y1);
    pos1 = spr->getPosition();
    spr->setPosition(pos1*posParam);
}

Don’t know whether it is a correct method or not?

If you know any other way share the same.