Hi. I have a RectangleShape that I'm trying to make gradually change to white as I hold a key. Actually, I've succeeded in this, but now I'd like a different key to gradually turn it black. It seems, however, that the minus operator will not work with sf:Color like the plus operator does.
To change my shape to white, I've used this code in the game loop.
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
sf::Color shapeColor = shape.getFillColor();
if(shapeColor != sf::Color::White)
shape.setFillColor(shapeColor + sf::Color(1, 1, 1));
}
I could only imagine this very same code with a "-" in place of the "+" (and sf::Color::Black instead of White, and a different Key) should do the opposite.
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
sf::Color shapeColor = shape.getFillColor();
if(shapeColor != sf::Color::Black)
shape.setFillColor(shapeColor - sf::Color(1, 1, 1));
}
However, that only gives me compiler errors that I don't entirely understand (I will post them if needed). Could somebody tell me why this won't work?