Hi @zhangxm, I have encountered issues with the positions when loading the ui in cocos2dx from the exported files.
Some of the positions look desirable, while some do not.
How it looks like in Cocos Creator.
How it looks like in Cocos2dx
Hi @zhangxm, I have encountered issues with the positions when loading the ui in cocos2dx from the exported files.
Some of the positions look desirable, while some do not.
How it looks like in Cocos Creator.
How it looks like in Cocos2dx
Will you please send me the creator project to reproduce it?
Thanks.
@Darren_86 i sent the PR to fix it: https://github.com/cocos2d/creator_to_cocos2dx/pull/92. I met problem when parsing your scene, back ground image
missed in EditBox, it is needed in cocos2d-x. I think you can use an transparent image to fix it.
And i find your project doesnāt have design resolution setting, i suggest adding a Canvas
node as the root of Scene.
@zhangxm thank you for the fix!
ah yes i have missed out sending to you the back ground image and also for the EditBox iāve modified the parser to allow no image and i create it in the reader code instead.
Indeed after iāve added the Canvas node, the positions of all the items now look exactly like it is in the Creator. Except for the labels in the icons at the right hand side - their positions appear to be lower
than how it is in Creator.
Did you modify engine too? Or could you please share me how you make it work?
Maybe it is something with the PR i sent? I tested in other scenes, havenāt found it. Could you please share a creator project too? Thanks.
Basically in CreatorReader::createEditBox i just hard-coded the sprite to be used for the EditBox creation.
cocos2d::ui::Scale9Sprite* sprite = cocos2d::ui::Scale9Sprite::create(āUI/ui_retangle_cruved_transparent.pngā);
sprite->setOpacity(0);
auto editBox = ui::EditBox::create(cocos2d::Size(contentSize->w(), contentSize->h()), sprite);
And iāve just sent you the project now with the canvas.
Got it. You can set the background in plugin, it is more convenient. I have to handle v3.16 releasing these days, so i will look at the issue later.
Somethingās wrong with design resolutionā¦
Iāve created an empty project with default Canvas settings (960x640 design resolution, Fit Height) and then Iāve added a simple background (1136x768) inside it.
In editor it looks like this:
Now, in settings Iāve set Simulator Resolution to iPhone 5 (1136x640) and they ran it:
Looking fine, we can see centered image and extended viewport on both sides, because iPhone5 (1136x640) is wider than design resolution (960x640).
Now, Iām trying to run the same thing from cocos2d-x project. Iāve removed all default design resolution code.
Scene* HelloWorld::createScene()
{
creator::CreatorReader* reader = creator::CreatorReader::createWithFilename("creator/scene1.ccreator");
// will create the needed spritesheets + design resolution
reader->setup();
// get the scene graph
Scene* scene = reader->getSceneGraph();
return scene;
}
That gave me this result on iPhone 5 simulator:
Iāve even tried replacing setup() code with this:
void CreatorReader::setup()
{
auto director = cocos2d::Director::getInstance();
auto glview = director->getOpenGLView();
glview->setDesignResolutionSize(960, 640, ResolutionPolicy::FIXED_HEIGHT);
setupSpriteFrames();
setupCollisionMatrix();
}
and got this result:
Whatās wrong?
@piotrros sorry, i can not see the picture, it seems there is an issue of the forum. I have reported the issue to forum maintainer.
@slackmoehrle do you know the reason?
@piotrros i tried to update a picture, there is not problem, i can see it. Could you please send me the picture you uploaded? We are curious if it is something related with the picture.
Thanks.
I will look at why.
Itās a JPEG 1136x768 pixels.
@piotrros i can see this file, but i can not see it in your above post, it is strange, could you please modify your above post to upload the pictures again? Thanks.
Iāve edited my post, please take a look.