Hey, I have a weird issue.
So, I have this method that should make 8x8 sprites from a spritesheet and put them into a list of sprites, which it does.
however, when I spawn a sprite, It shares the same texture as the very last Sprite in the list.
So, Sprite 1 should have texture 1, but it has the texture of sprite 128.
This is the same for every sprite in my list.
How would I resolve this?
If I was going to take a guess, I'd need to also store the texture somehow? perhaps in a second textures vector? but then whenever I loaded a sprite I'd need to set the texture of it equal to the texture at the same position in the sister vector? I feel like I'm overcomplicating this/doing it the wrong way.
http://imgur.com/gfkiCbb
Any help would be appreciated.
void SpriteMaker(int dimension, int scale)
{
int c = 0, r = 0, y = sheetIMG.getSize().y, x = sheetIMG.getSize().x;
do
{
for (int i = 0; i <= (x * y) / 64; i++)
{
if (r == 64)
break;
if (!tex.loadFromImage(sheetIMG, IntRect(c, r, dimension, dimension)))
break;
else
{
Sprite spr;
spr.setTexture(tex);
spr.setScale(scale, scale);
Spritesheet.push_back(spr);
c += dimension;
if (c == x) { c = 0; r+=8; };
}
}
} while (r < y);
}