# Making color of sprite darker or lighter

Is there any way to make a sprite darker or lighter in AndEngine? I dont want to use the alpha thing. Nor I want to loose the texture/design of the image.

One way in 2D Android to do darken or perhaps even to make it lighter is to use the lighting color filters:

Paint myPaint =  new Paint(Paint.ANTI_ALIAS_FLAG);
myPaint.setColorFilter(new LightingColorFilter(Color.rgb(120, 176, 209),0));


public LightingColorFilter (int mul, int add) Since: API Level 1 Create a color filter that multiplies the RGB channels by one color, and then adds a second color, pinning the result for each component to [0..255]. The alpha components of the mul and add arguments are ignored.

However, this can a bit diminish the color detail on the sprite.

• I am using AndEngine. These options are not available there/ – Jawad Amjad Aug 1 '12 at 6:17
• Can you alter the texure and then swap it in the openGL object in AndEngine? I don't know AndEngine but if it is using OpenGL then there should be an OpenGL function which sets the luminosity (GL_LUMINANCE) and other parameters of the object. – Lumis Aug 1 '12 at 21:18
• yes it is using OpenGl. Let me find if I can set the luminosity of the object. – Jawad Amjad Aug 3 '12 at 4:18

For my opinion you have to use setColor method of the sprite to make it darker and lighter. To make darker sprite you have to use

sprite.setColor(180f / 255f, 180f / 255f, 180f / 255f);


To make lighter sprite again you have to use

sprite.setColor(1f, 1f, 1f);

• Ok im giving it a try lets see what happens. – Jawad Amjad Aug 3 '12 at 4:17