frank84 Posted July 23, 2014 Share Posted July 23, 2014 Hello there, I'm just starting with Phaser, so sorry about this very basic question. I can't seem to successfully update the color of a Rectangle. Here is my code so far: // drawing playerthis.player1 = new Player(0, 20, "0xFFFF33");this.player1.graphic = this.game.add.graphics(this.player1.size,this.floor.base-this.player1.size); this.player1.graphic.beginFill(this.player1.color, 1);this.player1.graphic.drawRect(0, 0, this.player1.size, this.player1.size); update: function() { this.player1.graphic.graphicsData[0].fillColor = this.player1.breakdown ? '0XFF0000' : '0XFFFF33';} The following do update the color, but I need it to change only when certain conditions are met: update: function() { this.player1.graphic.graphicsData[0].fillColor = '0XFFFF33';} There is probably a method I can call to update the color, but looking at Phaser/Pixi docs I can't seem to find anything. Thanks for your help! Link to comment Share on other sites More sharing options...
esteban.guelvenzu Posted July 23, 2014 Share Posted July 23, 2014 maybe the problem is that you use "0xFFFF33" instead of 0xFFFF33 Link to comment Share on other sites More sharing options...
lewster32 Posted July 23, 2014 Share Posted July 23, 2014 Yeah, that's right - with Graphics you use literal numbers, so 0xffff33 (which is a hexadecimal representation of a number in JavaScript), not a string. Link to comment Share on other sites More sharing options...
frank84 Posted July 24, 2014 Author Share Posted July 24, 2014 Awesome thanks guys Link to comment Share on other sites More sharing options...
Recommended Posts