SFML community forums

Help => Graphics => Topic started by: underww on November 29, 2013, 03:54:12 pm

Title: Change sprites color problem.
Post by: underww on November 29, 2013, 03:54:12 pm
I'm trying to make short white blink effect as a result of collisions.

but I can't change sprite's color to white because white color is default color on sprite class.

so, is there any solution for this problem?

Thanks and I'm sorry for my poor English, I hope you understand my question.
Title: Re: Change sprites color problem.
Post by: Laurent on November 29, 2013, 03:58:51 pm
You can draw a white semi-transparent rectangle on top of your sprite. You can play with its alpha component to make it more or less transparent, create fade effects, etc.
Title: Re: Change sprites color problem.
Post by: underww on November 29, 2013, 04:23:33 pm
Thanks for replying so quickly.

but another problem is that the sprite has alpha channel.

so, white semi-transparent rectangle makes background also white.

how can I handle this issue?
Title: Re: Change sprites color problem.
Post by: Nexus on November 29, 2013, 04:44:45 pm
The simplest would be to have a separate texture where the sprite comes in white, and draw the white version on top of the normal one, possibly using alpha blending.

You could also use a fragment shader that makes the sprite appear white, but this requires knowledge about GLSL.