Ninjadoodle Posted September 19, 2018 Share Posted September 19, 2018 Hi @enpu / Panda People Is there a way I can change the FillColor or FillAlpha of a graphic once it's been created - let's say when I press a button? I'm trying right now but can't seem to get it working. Thank you! Quote Link to comment Share on other sites More sharing options...
Wolfsbane Posted September 19, 2018 Share Posted September 19, 2018 Doesn't look like it. I think Graphics are bitmaps, rather than a list of drawing commands, so once it's created, changing what FillColor to use shouldn't affect anything unless you draw to the Graphic again. I haven't though of a way to do colour blending, yet, which I want to to make the particles prettier. For alpha, just making sure you need FillAlpha, or you can just use .alpha? Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted September 19, 2018 Author Share Posted September 19, 2018 Hi @Wolfsbane Thanks for the reply - I've decided to create an outline graphic and fill graphic. That way I can show or hide whichever one I need. It's a workaround, but it works well Thanks again! Quote Link to comment Share on other sites More sharing options...
enpu Posted September 19, 2018 Share Posted September 19, 2018 Sure you can. Graphics object has shapes array which contains all shapes that your object has. So for example if your Graphics object has only one shape, just change fillColor property of the first shape in the shapes array: game.createScene('Main', { init: function() { this.grap = new game.Graphics(); this.grap.drawRect(0, 0, 100, 50); this.grap.addTo(this.stage); }, click: function() { this.grap.shapes[0].fillColor = 'red'; } }); 5 hours ago, Wolfsbane said: I think Graphics are bitmaps, rather than a list of drawing commands Graphics is a list of drawing commands Wolfsbane 1 Quote Link to comment Share on other sites More sharing options...
Wolfsbane Posted September 19, 2018 Share Posted September 19, 2018 Wait, let me check what I've been drinking. ...water? O.k. no excuses. My bad. But good to know! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.