Jump to content

How can I combine the text on phaser?


sinanqd10
 Share

Recommended Posts

How I can combine the text properties in a variable for using globally?

 

Thanks you in advance for helping !

var text = game.add.text(game.world.centerX, game.world.centerY + 50, 'Challenge your friends!');    text.font = 'Arial'; // here it is the property of phaser    text.fontSize = '12px';  // here it is the property of phaser    text.align = 'center'; // here it is the property of phaser    text.fontWeight = 'bold'; // here it is the property of phaser
Link to comment
Share on other sites

  • 2 weeks later...

You can save the attribute values in a global object that you can access from anywhere.

var _globalObj = {  fontSize: 12,  color: "#ff0000",  font: "Arial"};

And then simply call 

var text = game.add.text(game.world.centerX, game.world.centerY, 'test', _globalObj);
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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