Hello, I'm having a bit of a problem here and I can't quite see why.
I have a folder that contains 16 images and I want to render them to the screen and spread them out.
This is how I load them. I want all items to show up, but instead only 1 item shows up in 16 different positions...
sf::Sprite mazeSprite[16];
initialize()
{
sf::Texture texture;
std::string filePath = "C:/users/enok/desktop/sprites/cube";
float x = 10, y = 10;
for (int i = 0; i <= 15; i++)
{
std::string id = std::to_string(static_cast<long long>(i)) + ".png";
texture.loadFromFile(filePath + id);
mazeSprite[i].setTexture(texture);
mazeSprite[i].setTextureRect(sf::IntRect(10,10,32,32));
mazeSprite[i].setPosition(x,y);
x+= 20;
std::cout << filePath + id << std::endl;
}
}
this is the same sprite lined up 16 times.
http://puu.sh/8p4jz.pngThis is the render() function
rWindow.clear();
for(int i = 0; i <= 15; i++)
{
rWindow.draw(mazeSprite[i]);
}
rWindow.display();