SFML 2.0 changing alpha

I want to change the alpha of a sprite without changing any other colours do you know how to if it can be done?
Last edited on
sprite.setColor(sf::Color(255, 255, 255, 127));

replace 127 with any number in range [0, 255]
Last edited on
closed account (1yR4jE8b)
The alpha attribute is a public field of the sf::Color class, you can set it directly:

http://sfml-dev.org/documentation/2.0/classsf_1_1Color.php#a56dbdb47d5f040d9b78ac6a0b8b3a831
Last edited on
The alpha attribute is a public field of the sf::Color class, you can set it directly:


An sf::Sprite is not an sf::Color, so I'm not sure how that is relevant.

The relevant documentation:
http://sfml-dev.org/documentation/2.0/classsf_1_1Sprite.php#a14def44da6437bfea20c4df5e71aba4c

The code tntxtnt posted would reduce the alpha to half of whatever it was in the sprite's texture.
closed account (1yR4jE8b)
Shit. I read it wrong, getting late where I'm at and my brain is not working 100% lol.

Topic archived. No new replies allowed.