Jump to content

Centering BitmapFont (working with regular text)


kidos
 Share

Recommended Posts

I was trying to center my text on x point.

I mean - I have a graphic placeholder for the score text, everything is working well but if the score is getting more figures the text is written right to left and the then it's getting out of the placeholder.

 

In a regular text font I just add:

this.scoreText.anchor.setTo(0.5,0);

and the text is centered to the middle.

 

Unfortunately the bitmapfont doesn't have this kind of member.

 

Any ideas?

Link to comment
Share on other sites

both are working great but from some reason it doesn't work with fixed to camera text, and my text is fixed to the camera :)

Any ideas?

ahh find it!! :)

 

Since fixed to camera set the X (and Y) to the camera offset it can't be moved.

But, we could use this one:

this.scoreText.cameraOffset.x = this.posX - (this.scoreText.textWidth * 0.5);

Thank you both!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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