Hi all, I am using vectors to loop the amount of sprites that are rendered to my game screen.
//load the invaders images
sf::Texture invaderTexture;
invaderTexture.loadFromFile("images/invaders.png");
std::vector<sf::Sprite> invaderSprites(10, sf::Sprite(invaderTexture));
while (App.isOpen())// Process events
{
for (int i = 0; i < 5; i++)
{
invaderSprites[i].setPosition((60*i) + 50, 10);
}
for (int i = 0; i < 5; i++)
{
App.draw(invaderSprites[i]);
}
App.draw(back);
App.display();
}
This works perfectly, and I also found out that I was stupidly rendering the invaders and then the screen in past "issues". Now, SFML 2.0 classes aren't working with this code if they are out of the for loop:
Error: class "std::vector<sf::sprite, std::allocator<sf::Sprite>>" has no member "setPosition"
Putting everything in my for loop will just, diminish certain working parts for my game. I've tried doing
sf::Sprite<SpriteNameHere> but that wont rectify my issue. Any ideas here? Will this be one of the issues where I have to change everything?