Changing a Sprite Color

Hi! I have a sprite (a simple red square) when I click on it I want it turns to yellow.
My code is when button was released change color to “248;231;28” (yellow). But it remains red.
Does it only change into yellow if its original color is white?

1 Like

@zutty Hi. Yes, unfortunately the color change works differently in sprite & tiled sprite objects than it does on Text or the shape painter.

To put it simply the color model used is messed up. So you would certainly need to make the base color of your sprite to be pure white (255,255,255) if you want to have the most control of the color when using this action with sprite & tiled sprite objects.

There’s also a new thing called layer effects, which might help you change the color, but I have not used them. So possibly putting your square in that layer so it’s only affected by the effect might also work, but bear in mind this is pretty new, so there might not be enough effects to use.

http://wiki.compilgames.net/doku.php/gdevelop5/interface/scene-editor/layer-effects

I think we might need to ask the developers for a revision on this effect or to have real sprite hue/saturation color effects as this thing is not exactly fulfilling the intended use :pensive:

Thanks Jose! Makes no sense to have an Action that actually doesn’t make what it’s supposed to do.

@zutty Yes I agree, and what’s more puzzling is that this effect works perfectly for fonts which as far as I know are rendered as textures on the game after the canvas is created, so it should work. I think we probably need to report it as a bug, but i’m too busy for now. Maybe in december. Good luck anyway!

Yep, it works flawlessly on fonts, that’s why I thought it should work on sprites too. I’ll report this as a bug. Good luck you too.

I was going to ask about this today, but the problem remains sadly, I was so confused too…
Well I guess I’ll turn it to white then change it to whatever I want.
Thanks Jose for explaining, hope it gets fixed in the next beta.

When we change the colors of a specifed sprite with a colors, think blend color when your mix painting colors.

If you board is white you can change it in black, purple, yellow. The color you want.

If your have a board (or a sprite) red and you mix the yellow, your sprite will be orange.
It’s same in GDevelop.
(Tell me if I’m talking nonsense)

You can’t change red sprite in other colors.
Or we need add a function for change the colors of a specified sprite.
In this case in the next release you will be able to change the colors of layer, where is located your sprite.
Change the red color in yellow or green or what ever.

But the actual function for change the color is thinking like when you mix the colors of paint.

1 Like

Thinking so, the same should occurs on fonts. If we could change color we shouldn’t need to mix them. Mix color is not useful at all. IMO.

1 Like

You can use different animations using different colors.

Hello!

Please do not bump multi-year old threads.

Thank you!