Vizcur Posted November 24, 2017 Share Posted November 24, 2017 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 Phaser: Link to comment Share on other sites More sharing options...
samme Posted November 28, 2017 Share Posted November 28, 2017 https://photonstorm.github.io/phaser-ce/Phaser.Text.html#setTextBounds Link to comment Share on other sites More sharing options...
Vizcur Posted December 4, 2017 Author Share Posted December 4, 2017 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. Link to comment Share on other sites More sharing options...
samme Posted December 4, 2017 Share Posted December 4, 2017 What container? Link to comment Share on other sites More sharing options...
Vizcur Posted December 6, 2017 Author Share Posted December 6, 2017 The one shown when using the function: game.debug.spriteBounds(myText); Link to comment Share on other sites More sharing options...
samme Posted December 6, 2017 Share Posted December 6, 2017 If you want vertical alignment within a container you need to use setTextBounds. Then adjust text.padding.y if needed. Link to comment Share on other sites More sharing options...
samme Posted December 6, 2017 Share Posted December 6, 2017 Link to comment Share on other sites More sharing options...
Recommended Posts