Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Change sprites color problem.  (Read 1473 times)

0 Members and 1 Guest are viewing this topic.

underww

  • Newbie
  • *
  • Posts: 34
    • View Profile
Change sprites color problem.
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Change sprites color problem.
« Reply #1 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.
Laurent Gomila - SFML developer

underww

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: Change sprites color problem.
« Reply #2 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?
« Last Edit: November 29, 2013, 04:48:03 pm by underww »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Change sprites color problem.
« Reply #3 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: