miguelgazela Posted March 26, 2014 Share Posted March 26, 2014 I'm trying to draw a health bar for my player, but I can't seem to find how to change the size of a previously drawn rectangle using the Graphics.drawRect function. Is there a way to clear all graphics and then re-draw them again with the updated values? Link to comment Share on other sites More sharing options...
localGhost Posted March 26, 2014 Share Posted March 26, 2014 Well, if clearing and then redrawing would satisfy you, then you may actually use clear() on the graphics object.bar = game.add.graphics(10, 10);bar.drawRect(0, 0, 100, 20);...bar.clear();bar.drawRect(0, 0, health, 100);Or am I missing something? Link to comment Share on other sites More sharing options...
miguelgazela Posted March 26, 2014 Author Share Posted March 26, 2014 Yeah, that's what I was looking for. I searched in the documentation, but there's no clear method in the Graphics class description. Link to comment Share on other sites More sharing options...
localGhost Posted March 26, 2014 Share Posted March 26, 2014 I might be wrong since I'm quite new to JS overall, but I guess that's because it relates to the 'normal' canvas already, not just something Phaser is providing. Link to comment Share on other sites More sharing options...
Recommended Posts