Alright, I switched from SDL to SFML a few days ago, compiled 2.0 libraries and am currently using that.
In my code I create a struct for a sprite and fill the information in with a given function.
uint cSpriteManager::CreateSprite(string File, float X, float Y, uint TotalFrames, uint TotalAnimations, uint FrameWidth, uint FrameHeight, Uint32 Delay, int Repeations)
{
uint SpriteID = m_Sprites.size() + 1;
sSprite NewSprite;
NewSprite.nTexture = LoadTextureFile(File);
NewSprite.Animation = CreateAnimation(TotalFrames, TotalAnimations, FrameWidth, FrameHeight, Delay, Repeations);
NewSprite.X = X;
NewSprite.Y = Y;
m_Sprites[SpriteID] = NewSprite;
return SpriteID;
}
Texture cSpriteManager::LoadTextureFile(string filename)
{
Texture Temp;
Temp.LoadFromFile(filename.c_str());
if (!Temp.LoadFromFile(filename.c_str()))
{
cout << "cSpriteManager: Could Not Load File " << filename.c_str() << endl;
exit(1);
}
Temp.SetSmooth(true);
return Temp;
}
There is no problem with this, it returns the Temp texture and fills it into NewSprite.nTexture no problems, the problem is trying to access it. I define the container for all the sprites as:
private:
map<uint, sSprite> m_Sprites;
and I have a function that I call to return the texture to display, since it is private, which is:
Texture cSpriteManager::GetTexture(uint SpriteId)
{
return m_Sprites[SpriteId].nTexture;
}
Once I have all my textures and information stored I run the following code:
Sprite.SetTexture(SpriteMan->GetTexture(SpriteId));
This just gives me a white shape where the sprite would display, but if I make the container public and call it with:
Sprite.SetTexture(SpriteMan->m_Sprites[SpriteId].nTexture);
It works just fine, I probably missed something very simple here, I was passing the Texture around when I first loaded it up, but it doesn't seem to be working now. I just don't understand whats going on after tinkering for an hour or so. I would greatly appreciate any opinions on the matter.