Jump to content

Appending Text on Text Object Causes New Line


JamesA
 Share

Recommended Posts

I'm just curious why whenever I append text to a text object it appears to go to the next line...

 

For example:

var chatText = game.add.text(0, 0, "Name: ", style);

chatText.text += "hello I'm James"

 

will appear in the game as:

Name:

hello I'm James

 

Word wrap is disabled, if I display the text in the console it says Name: hello I'm James

 

Thanks if you have any info.

Link to comment
Share on other sites

Hi,

Maybe there is a problem with the style.
This works perfectly in the on line Sandbox Phaser editor:

function create() {

    var style = { font: "bold 32px Arial", fill: "#fff"};
    
    var mytext = game.add.text(0, 0, 'My own text:', style);
    mytext.setText(mytext.text+' This is my text.');
    
    var mytext2 = game.add.text(0, 50, 'My own text2:', style);
    mytext2.text+=' This is my text2.';

}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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