Fill color area in a sprite


Is there a way to fill an area in a sprite with a color ?
Just like in any drawing softwares when you want to fill an closed area.



Tint color seems to work pretty well if your starting color is white. The tint will mix with whatever your existing color is. But did you need some other way of doing it?

I think @Devnvow means the flood tool.

And the answer to that is not easily in GDevelop. You could if you used a JavaScript event and changed pixels on the sprite, but it would probably be slow.

You could possibly fake it with a sprilte/alpha mask, but that uses 3 sprites, is clumsy and not the best way of acheiving it.

Flood tool, like bucket? So that it would leave the lines black or whatever and fill in the enclosed bit? Hmmm, yes, I get it and I assume that’s what you’re referring to with masks but I don’t know about that stuff yet. I guess a Bubble* type solution would be to have the outline sprite and the white/clear slightly smaller one inside it and tint that.

*Might work but probably much better ways out there.

I guess if you make the sprite different colors of greyscale, you could use the color replace object/layer effect to initially set your “normal” colors, then events to replace an existing color with a new one later on as if it was a “fill” tool?

That’d get you close to the desired effect. That said, if you have multiple uses of the same color in different areas, it’d change those too.

Ok thanks. So it will be difficult… :slight_smile:

HI @Silver-Streak
I suggest you to use mask or change animation or create a sprite over the main one.

Yes, I think I will use animation.

In fact, it is for a strategy game (imagine a Risk game) with area/country to conquer.

When you conquer an area, the won area is flooded with your own player color.

So, I need to use a sprite by country and not a map with all my countries…

A bit longer and tricky …

In that case, I’d suggest you make each country a pure white sprite, put them together like jigsaw puzzle pieces and set their colour using the sprite tint option. To me that would be the best solution.

1 Like

Yes it is a good idea !