It multiplies the colour you give it with the colours in the texture. White would mean that it allows all colours to pass through unmodified. Other colours tint the texture. Imagine holding different coloured glass/plastic over the texture image; white would represent clear.
EDIT: Also, you wouldn't be putting an sf::Color as a paramter to sf::Color.
Try this:
sprite.setColor(sf::Color::Red);
It multiplies the colour you give it with the colours in the texture. White would mean that it allows all colours to pass through unmodified. Other colours tint the texture. Imagine holding different coloured glass/plastic over the texture image; white would represent clear.
EDIT: Also, you wouldn't be putting an sf::Color as a paramter to sf::Color.
Try this:
sprite.setColor(sf::Color::Red);
Thanks @Golden Eagle but it still doesn't work ;/
My code looks like below:
sf::Texture texture;
texture.loadFromFile("ball.png");
sf::Sprite sprite;
sprite.setTexture(texture);
sprite.setPosition(100, 25);
sprite.setColor(sf::Color::Red);
And Sprite changed a color but not for Red but almost black. I tried set meny of colors but it changed for black only.
I afraid it's not allowed to manipulate of color of a file ;/
And Sprite changed a color but not for Red but almost black. I tried set meny of colors but it changed for black only.
I afraid it's not allowed to manipulate of color of a file ;/
I would assume that your original image is red if it's dark when tinted red and black when tinted with other colours?
I don't think I explained the multiply thing very well. I'll try again:
Each pixel's colour in the texture/image is represented by three values - red, green, blue. The colour that you specify in sprite.setColor() instructs SFML which colours to allow to be seen.
Assume that one of the sprite's pixels is yellow.
// sf::Color(<red value>, <green value>, <blue value>)
// yellow: allows the red and green components of the yellow to be shown
// therefore, yellow is displayed
sprite.setColor(sf::Color(255, 255, 0));
// red: allows the red component of the yellow to be shown
// therefore, red is displayed
sprite.setColor(sf::Color(255, 0, 0));
// green: allows the green component of the yellow to be shown
// therefore, green is displayed
sprite.setColor(sf::Color(0, 255, 0));
// white: allows the red, green, and blue components of the yellow to be shown
// therefore, yellow is displayed (there is no blue component in yellow)
sprite.setColor(sf::Color(255, 255, 255));
// magenta: allows the red and blue component of the yellow to be shown
// therefore, red is displayed (there is no blue component in yellow)
sprite.setColor(sf::Color(255, 255, 0));
// blue: allows the blue component of the yellow to be shown
// therefore, black is displayed (there is no blue component in yellow)
sprite.setColor(sf::Color(0, 0, 255));
// black: does not allow any components to be shown
// therefore, black is displayed
sprite.setColor(sf::Color(0, 0, 0));
EDIT: shortened lines in code