I am making a 2d platformer in java using the slick2d engine. I only use 2 colors: black and white. I want to implement a feature were i invert the colors of certain entities. However i can't find a way to do this. Anyone knows of an easy way or function?

  • \$\begingroup\$ Are the entities loaded from file or drawn by in java? Both cases would support Tinting however I unsure if tinting black with white would work :) \$\endgroup\$ – AbstractChaos Aug 8 '12 at 15:49
  • \$\begingroup\$ The graphics are loaded from spritesheets. \$\endgroup\$ – Malthe Lange Aug 8 '12 at 15:59

Try this on white one first, add this Color test = new Color(0f,1f,0f); then in your render method using your sprite sheet do.


//draw sprites


If this works then you could simply have a single sprite sheet (of all white) and color it anyway you wish.

Hope it helps

| improve this answer | |
  • \$\begingroup\$ I tried using the above on one of my enemies' animation: if(manager.inverted && verticalDir == LEFT){ Color test = new Color(0f, 1f, 0f); moving.getCurrentFrame().startUse(); test.bind(); moving.getCurrentFrame().draw(position.x, position.y); moving.getCurrentFrame().endUse(); } It just stopped my entities from being rendered at all P.S: I can't get the code tags to work on this site \$\endgroup\$ – Malthe Lange Aug 8 '12 at 21:43
  • \$\begingroup\$ @MaltheLange could you post your render code? \$\endgroup\$ – AbstractChaos Aug 9 '12 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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