Jump to content

Change text colour dynamically


gwinnell
 Share

Recommended Posts

Hi all,

 

Is this possible? e.g. 

// Create textvar t = this.game.add.text(10, 10, "Hello World", { font: "16pt Arial", fill: "#FFFFFF", align: "center" });// Ideally not this because it uses internal values, and actually doesn't update the text displayed. t._style['fill'] = "#FF0000";// Perhaps something like this...!t.updateCSS({ font: "16pt Arial", fill: "#FF0000", align: "center" });

Thanks!

Link to comment
Share on other sites

setStyle() is inherited from PIXI.Font, so it is found in the PIXI docs, not the Phaser docs.
What you find in the Phaser docs is the Text.font property:

/*** The font the text will be rendered in.* @name Phaser.Text#font* @property {string} font - The font the text will be rendered in.*/Object.defineProperty(Phaser.Text.prototype, 'font', {    get: function() {        return this._style;    },    set: function(value) {        //  Let's not update unless needed, this way we can safely update the text in a core loop without constant re-draws        if (value !== this._style)        {            this._style = value;            this.setStyle(value);        }    }});
Link to comment
Share on other sites

  • 2 years later...
 Share

  • Recently Browsing   0 members

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