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.

In MonoGame I am using SpriteBatch to draw sprites. I want to create a semi transparent overlay that would 'tint' the sprite with a given color. SpriteBatch.Draw accepts Color parameter that allows to specify the tint, however the alpha channel seems to make the whole sprite transparent (not the tint only).

To address the problem i am overlaying my sprites with another white, semitransparent sprite tinted to a given color. It works as expected, but I am not sure if that is the correct (and most optimal) approach.

Can you suggest better/faster technique?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

Don't use a color with alpha in the SpriteBatch.Draw(...Color). Your sprite's transparent parts will stay that way, and their opaque parts will be tinted.

share|improve this answer
    
sorry maybe I wasnt clear, my sprite is opaque (no transparency), its just when i use SpriteBatch.Draw with eg. Color.Green the tint is too strong, i would like it to be Color.Green with 30% opacity. –  Piotr Walat Oct 21 '12 at 8:32
    
In that case, try using something that is almost white. Like Color(250,255,250) –  Seth Battin Oct 21 '12 at 8:34
    
thanks! that's a correct answer. Now it seems obvious :) –  Piotr Walat Oct 21 '12 at 9:00
add comment

"Color.Green the tint is too strong, i would like it to be Color.Green with 30% opacity."

I think you mean saturation, not opacity. Here you go:

Color desaturatedGreen = Color.Lerp(Color.White, Color.Green, 0.3f);
share|improve this answer
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.