Jump to content

How to change the color of a rectangle in update function?


Serdar
 Share

Recommended Posts

I have created a rectangle and attached it to a sprite. (I'm not sure if this is the right way to create a shape, tell me if it's not.)

 

Now I want to change the color of this rectangle dynamically. I have looked into many color related methods with no success. How to do that?

var sprite;var graphics;function create() {		game.physics.startSystem(Phaser.Physics.ARCADE);		graphics = game.add.graphics(0, 0);	graphics.beginFill(0xFF700B, 1);	graphics.drawRect(0, 0, 100, 100);	sprite = game.add.sprite(0, 0);	sprite.addChild(graphics);}function update() {	if (game.input.activePointer.isDown) {				//i want to change the color of the rectangle here		}}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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