0 votes

Hi everyone,

I have a character built from four individual graphics (body, legs, head, ears), and they are all red. In the settings the users should be able to choose from different colors via checkboxes, so let's assume they tap on green...

I'd like the character to instantly swap colors and I assume that's doable. My beginner-mind thinks of a folder containing sub-folders in each of which the same four character-graphics are being stored in their respective color. For the game itself ("in the memory") there is a folder with the currently used graphics, currently filled with the red ones. Changing to green would erase these red versions and instead copy the green versions in place. (The idea is to have the single graphics always to be named the same although coming from within different color-folders, so the code wouldn't mind...)

Would that be a good way to do this?

in Engine by (365 points)

1 Answer

0 votes

I'm not totally sure what you have done, but assuming you have sprites for the body, legs etc. then perhaps use the modulate function on the sprite. When I do something similar, I just use white sprites and then set the color like this:
var green = Color(0.2, 1.0, 0.0, 1.0)
var red = Color(1.0, 0.0, 0.0, 1.0)
$Sprite1.modulate = green
$Sprite2.modulate = red

Hope it helps or others chime in with the solution for you

by (18 points)

Thanks for your suggestion. I thought about pointing out that modulating isn't an option in this case, now I know that I should have, sorry, but thanks anyway!

In my case I'm using individual sprites because they all base on their own hand made original. And I generally am interested in how to approach such a case, with emphasis on the loading/erasing aspect. I think I could load all the versions with all individual names and then organise them in code, but that would be lots of manual work (and data), so I was wondering if the idea of one folder for the current version makes sense in the first place.
I don't dare asking about the how before the comunity greenlights the if ; )

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.