Jump to content

Setting text width and automatic wrapping


samjarman
 Share

Recommended Posts

How do I set text box width and allow the text to wrap automatically? it seems fairly weird to have to put '\n's in everywhere, especially with text I don't define. 

 

Also, with the x and y in the constructor... is that top left, centre? centre top? The docs dont say as far as I can see :/

 

Cheers!

Link to comment
Share on other sites

Here is my full code with it all working, in case anyone is curious

      var information = this.game.add.text(10, 100, this.generateFeedback());      information.font = 'Open Sans';      information.wordWrap = true;      information.wordWrapWidth = 790; //790 and 10 above to try do some padding      information.align = 'center';//I thought this would cause all text to move to center, but only seems to work for one line.       information.fontSize = 35;      information.fill = '#FFFFFF';      titleText.anchor.setTo(0.5, 0); //centers text for one line
 
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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