Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a form to change the color of a sprite in runtime?}

I have a black point loaded with an image, but i dont want to load various images with different colors, is there a mode to change the color in runtime and not loading lot of images?

And i want to tell it what part to color of the sprite, is it possible?

share|improve this question
up vote 8 down vote accepted

I had to do something like this in XNA with pixel-art sprites. The best way i've found was using pixel shader.

The sprites are done in gray-scale (8 bits colors without alpha), then you'll have to map each gray-color to the correspondent 32 bit color you want, using a 256 lenght array of Colors.

In the shader you can use the gray colors of the sprite as a look-up table to the array of 32 bit colors.

share|improve this answer
Yes, With the gray color i can tint my images :) and with the set color of the sprite i change the color. Thanks for that – Rudy_TM Mar 8 '12 at 17:46

If you refer to libgdx then the class provides two different methods called setColor:

share|improve this answer
Ok I missed the point. You just need to parse all the pixels of your sprite and simply change by another color when a pixel matches the color you want to replace. Be careful it can turns out to be very time-consuming in real-time that's why usually sprites can be pre-rendered in several variations of colors in the resources. – user14170 Mar 7 '12 at 13:37
Color c = new Color(batch.getColor());
batch.draw(yourSprite, x, y);
share|improve this answer
setColor(a,b,c,d) ?? Are you sure? – RichieHH Aug 25 '15 at 23:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.