I made a small project in C++ using SFML. I added sprites (a character). I have organized the sprites like Assets/Player/Idle/Idle1.jpg
then Idle2.jpg
and so on.
I initialize the sprites like this:
texture = new Texture[116];
sprite = new Sprite[116];
texture[0].loadFromFile("Assests/Iori/Ready1.png");
sprite[0].setTexture(texture[0]);
texture[1].loadFromFile("Assests/Iori/Ready2.png");
sprite[1].setTexture(texture[1]);
texture[2].loadFromFile("Assests/Iori/Ready3.png");
sprite[2].setTexture(texture[2]);
texture[3].loadFromFile("Assests/Iori/Ready4.png");
sprite[3].setTexture(texture[3]);
texture[4].loadFromFile("Assests/Iori/Ready5.png");
sprite[4].setTexture(texture[4]);
texture[5].loadFromFile("Assests/Iori/Ready6.png");
sprite[5].setTexture(texture[5]);
texture[6].loadFromFile("Assests/Iori/Ready7.png");
And so on. Now this method works fine and loads my sprites completely. But I don't think this is the efficient or right method. I have to load up 100+ sprites and that would just be a mess for a programmer.
I was wondering can you initialize these sprites via a loop (for/while) that would reduce the code a lot.