BitmapText align "center" does not align properly

Recommended Posts

I am experiencing an odd problem aligning the text of a BitmapText to the center.

I am successfully able to wrap the text by using the "maxWidth" property, but the alignment of the text is uneven / jagged (see attached screenshot).

It doesn't align to the center, some words are more to the left, and some are more to the right. I can't understand what's going on.

I am using the code below (typescript):

let hintText:Phaser.BitmapText =, 100, "MSR", "", 25, "center");
hintText.maxWidth = 310;
hintText.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut mattis velit. Cras placerat fermentum dictum. Donec at semper enim. Donec euismod pulvinar volutpat."



Share this post

Link to post
Share on other sites

The 'align' argument is for the alignment of multi-line text, it doesn't do anything if there is only one line of text. In your example, there is only one line of text, because there are no new-line characters anywhere in it.

maxWidth doesn't add in newline characters, which is why 'align' is unable to do anything in this case.

Personally I think the outcome is, rightly, unexpected though. You'd want it to do what you expect above, however the code to handle that isn't in the class file. PR anyone?

Share this post

Link to post
Share on other sites

Oh I see. Thanks for that Rich. :) Yeah, it seems there's currently no easy way to achieve that "centered" effect huh? Unless I manually add new lines.. I am starting to look at using Phaser.Text instead, maybe that one has more options for wrapping, etc. This is my first time using Phaser btw. I come from the Flash world.

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.

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.


  • Recently Browsing   0 members

    No registered users viewing this page.