Okay so the problem I have right now is that when I use getColor().r on a sprite object (.r, .g, or .b, it doesn't matter which), I have the console output the return value, but the value it returns is a mystery.
I thought it would return an integer value between 0 and 255, yet it only seems to return weird characters.
Here's my cut-down code:
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
srand((unsigned)time(NULL));
sf::RenderWindow Window;
Window.create(sf::VideoMode(400, 255), "My Title", sf::Style::Close);
Window.setVerticalSyncEnabled(true);
Window.setKeyRepeatEnabled(false);
sf::Texture tileTexture;
if (!tileTexture.loadFromFile("tile.png"))
{std::cout << "Error: Could not load block_grid image" << std::endl; return -1;}
std::vector<sf::Sprite> tileSprites(10, sf::Sprite(tileTexture));
tileSprites[0].setColor(sf::Color(rand()%256, rand()%256, rand()%256));
std::cout << tileSprites[0].getColor().r; // this returns a random symbol, such as Greek character
// For example, if I make the first parameter of the sf::Color(2, #, #), getColor().r returns a smiley face symbol.
//the rest of the code isn't important
}
So, am I doing something wrong, or is getColor() supposed to return its value like that? Thank you for reading.