Jump to content

Vertically centered text when using fixedHeight.


Recommended Posts

Phaser 3.55.2


I have a Phaser.GameObject.Text object.

When I initialize it, I pass a `fixedHeight` value in the config.

I would like the text to be vertically centered within this height.

I am aware that I can use origin to center the text given a specific point, but this is not about centering the text inside its container, but rather center it "within itself".


If you're wondering why I'm doing it this way: to leverage the Text object's `backgroundColor` prop, and avoid creating an additional object just to paint the Text's background.

Link to comment
Share on other sites

  • 8 months later...

  • Recently Browsing   0 members

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