Vizcur

Center text in container

Recommended Posts

Hi,
My query is this: I use the Cocos creator tool to position a text. When you export the position of this element and then integrate it into my phaser game, it happens that the selected position is slightly different from what is previewed in the Cocos tool.
I suspect it is due to how both tools draw the font in their respective container. As you can see in the attached images, in the tool the text is centered in its container, however, in Phaser, when debugging the edges of the text, you can see that the font is positioned upwards.
In short, both containers are in the same position but the texts are drawn in different positions.
Is there any way to modify how Phaser draws the text in his container?

As additional information, both texts are centered and added to a sprite as a child.
The way the text is positioned varies according to the font used.


Cocos tool
image.png.8b909302b01f923fd1bbe7a8656f3fd5.png
 
Phaser:
image.png.8c5ac2d0d352af61357ced18f4516f3a.png

Share this post


Link to post
Share on other sites

Thanks samme but that doesn't solve the problem. For each font you use I would have to calculate how much the shift is and my idea was to be able to have phaser draw the texts centered in his container.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.