Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
I assume you've see the forum post for this?: andengine.org/forums/gles1/… And this one: andengine.org/forums/gles1/… –  Byte56 Jul 31 '12 at 16:46
add comment

2 Answers 2

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.

share|improve this answer
    
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
add comment

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);
share|improve this answer
    
Ok im giving it a try lets see what happens. –  Jawad Amjad Aug 3 '12 at 4:17
add comment

Your Answer

 
discard

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.