Jump to content

text isn't aligning for me


stvrbbns
 Share

Recommended Posts

I am trying to make a menu screen with a centered title, some centered column headers, some right-aligned row labels, and some left-aligned row notes.

relevant examples:
Basics 06 Render Text
Text Bounds

relevant documentation:
Phaser.Text

This seems like it ought to be trivial, but none of my text alignment is working - it's all "left" all the time. I've tried declaring a non-left alignment (e.g. align:'center') on a style object before creating the text and I've tried assigning alignment to the text object immediately after creating it. Both of these methods appear to work trivially in the "Basics 06 Render Text" example. If I instead use anchor (e.g. .anchor.setTo(0.5,0.5) ), then that works.

-----

My problem was that I hadn't understood the text.align vs. boundsAlign and had missed a crucial comment in the documentation about text.align: "Does not affect single lines of text.". text.align only aligns the text within the area that the text is actually rendered in. A single line of text is already taking up 100% of the width and height of the rendered text area, so it is already "aligned" in all possible ways (i.e. it can't be moved left, right, up, or down without changing which area it is being rendered in). boundsAlign aligns a rendering of text within a set of bounds - but these bounds must be set.

Link to comment
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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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