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

This code colors the enemy red:


if I set it to:
it turns it pure black, and if I set it to
it turns the enemy invisiable

How do I un-color enemy red? as in return to state as it was before it was colored.

Documentation link.

share|improve this question
up vote 3 down vote accepted

Don't fiddle with the alpha at all if you're not wanting to change it. Use the non-alpha version.


Then create this method:

setCurrentColor(int r, int g, int b) {

Then when you want to return to no color, just texture, set the enemy to white:


Turns out there's a setImageColor function that Eric mentioned in his answer. I checked the source:

public void setImageColor(float r, float g, float b) {
    setColor(TOP_LEFT, r, g, b);
    setColor(TOP_RIGHT, r, g, b);
    setColor(BOTTOM_LEFT, r, g, b);
    setColor(BOTTOM_RIGHT, r, g, b);

So, setImageColor is not any different than calling setColor on all four corners. Just in case you were wondering.

share|improve this answer

You need to track the last color set before changing it red, and use that when you want to restore the color.

share|improve this answer
but there is no other colors, its just enemy.png image , when he gets hit, it changes red. – Matthew Apr 3 '13 at 16:27

An Image's default color is 1,1,1,1 (rgba) a.k.a. opaque (or non-transparent) white. Use Image.setImageColor to reset it:


Be sure to use this method instead of applying Image.setColor to each of the image's four corners.

share|improve this answer
it says setImageColor doesnt exist – Matthew Apr 5 '13 at 17:57
@Matthew Right, I corrected the code for your copy-pasting convenience. – Eric Apr 5 '13 at 18:02

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.