Well, I'm having a bit of a head-scratch here.
I understand that Sprites are references to Textures and the Textures need to be initialized for the Sprites to draw.
In this case, I have a vector of Textures in class TexMgr in which I store all tilesheets:
TexMgr.h:
std::vector<sf::Texture> tileSheets;
std::map<unsigned long, unsigned long> tileIDs;
TexMgr.cpp:
void TexMgr::addTilesheet(sf::Texture &tilesheet) {
tileSheets.push_back(tilesheet);
}
Now I want to store each tile in each tilesheet of the previous vector into a seperate Sprite vector:
TexMgr.h:
std::vector<sf::Sprite> sprTiles;
TexMgr.cpp:
void TexMgr::addTile(sf::Sprite &tile, unsigned long id) {
sprTiles.push_back(tile);
tileIDs[id] = sprTiles.size() - 1;
}
and finally draw the sprite using:
sf::Sprite* TexMgr::getTileSpr(unsigned long id) {
return &sprTiles[tileIDs[id]];
}
I don't think this is the correct way of doing things because the rendered Sprite is white.
Could anyone lighten me up, any help is appreciated.