user8340536 user8340536 - 3 years ago 103
Android Question

Change the color of a texture

is it possible to change a color of a texture to a random color and how can I do that if it's possible?
I think another way is to create a sprite sheet with the object in different colors and change the region randomly, but I don't know for sure.

Answer Source

If you have a white texture then you can just change the spritebatch colour to tint the image.

batch.setColor(new Color(r,g,b,a));
batch.draw(texture, x, y);
batch.setColor(new Color(1,1,1,1)); // reset to default colour
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download