sinanqd10 Posted December 24, 2014 Share Posted December 24, 2014 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 More sharing options...
NamBui Posted December 27, 2014 Share Posted December 27, 2014 I think this example can help you since the 4th param is the object defined for styling the text http://examples.phaser.io/_site/view_full.html?d=basics&f=06+-+render+text.js&t=06%20-%20render%20text&jsbin=http://jsbin.com/zagob/11/edit?js,output Link to comment Share on other sites More sharing options...
sinanqd10 Posted January 6, 2015 Author Share Posted January 6, 2015 sorry for late replying. What I want is to use phaser text properties. eg : fontSize , FontWeight which I want to combine these properties in order to reuse them again. Do you have any tricks? Link to comment Share on other sites More sharing options...
MichaelD Posted January 6, 2015 Share Posted January 6, 2015 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 More sharing options...
sinanqd10 Posted January 7, 2015 Author Share Posted January 7, 2015 @MichaelD . I did it before, but I still no luck with that. Link to comment Share on other sites More sharing options...
MichaelD Posted January 8, 2015 Share Posted January 8, 2015 Make sure to have the object declared outside of any functions so it will have global view (not the best solution however); Also mind that the object is the last one on the text function Link to comment Share on other sites More sharing options...
Recommended Posts