1
Graphics / passing texture through function
« on: December 23, 2011, 05:16:32 am »
Doh, thanks alot! You're my hero Turbine.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
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;
}
private:
map<uint, sSprite> m_Sprites;
Texture cSpriteManager::GetTexture(uint SpriteId)
{
return m_Sprites[SpriteId].nTexture;
}
Sprite.SetTexture(SpriteMan->GetTexture(SpriteId));
Sprite.SetTexture(SpriteMan->m_Sprites[SpriteId].nTexture);