Jump to content

bitmapText.width and textWidth after text change


ZoomBox
 Share

Recommended Posts

Hello !

 

When I change my bitmapText.text property the textWidth is not the good one.

Actually I create all my bitmapTexts with an empty string and then I set the texts and then the positions.

 

If I want to center my text, I can't because the textWidth is not correct at all (should be 300 and is around 30).

 

Thank you in advance.

Link to comment
Share on other sites

Do bitmapText.updateText() and it will calculate the correct textWidth there and then. This calculation is usually deferred until the next update, but if you need to change and then center the text, then this is the way to do it. 

bitmapText.text = "Some text.";bitmapText.updateText();console.log(bitmapText.textWidth); // will now be correct
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...