Jump to content

text align to right not working.


fkkcloud
 Share

Recommended Posts

this.game.add.text(me.game.world.width * 0.58,
            me.game.world.height * 0.65, 
            'hello', 
            {    font: headingFont, 
                fill: "#fff", 
                align: 'right',
            });

I am setting align text to 'right' like above but it does not get applied.

 

Link to comment
Share on other sites

The right alignment is being applied, you just aren't noticing because your text is only one line long ("hello").

Try changing your text to something with multiple lines:

this.game.add.text(me.game.world.width * 0.58,
            me.game.world.height * 0.65, 
            'hello\nalign-right\nexample', 
            {    font: headingFont, 
                fill: "#fff", 
                align: 'right',
            });

You should be able to notice the right-align being applied properly.

Link to comment
Share on other sites

  • 9 months later...

You could try to work with setTextBounds.

var myText = this.game.add.text(0, 0, 'hello align-right example', 
{
	font: headingFont, 
	fill: "#fff", 
	align: 'right',
	boundsAlignH: 'right',
	boundsAlignV: 'top'
});
myText.setTextBounds(0, 0, this.game.world.width, 0);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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