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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.