SFML community forums

Help => Graphics => Topic started by: JeZ-l-Lee on February 07, 2009, 09:39:32 am

Title: How do I center a Sprite while rotating and scaling Sprite ?
Post by: JeZ-l-Lee on February 07, 2009, 09:39:32 am
How do I center a Sprite while rotating and scaling Sprite ?

Code: [Select]
void Visuals::DisplaySpriteOntoScreenBuffer(uint16_t spriteIndex, float spriteX, float spriteY, bool centerX, sf::Color color, float scaleX, float scaleY, float rotation)
{
Sprites[spriteIndex].SetScale(scaleX, scaleX);
Sprites[spriteIndex].SetRotation(rotation);
Sprites[spriteIndex].SetCenter( (Sprites[spriteIndex].GetSize().x / 2), (Sprites[spriteIndex].GetSize().y / 2) );

if (centerX == true)
{
Sprites[spriteIndex].SetX(320); // Screen size is 640x640...
}
else  Sprites[spriteIndex].SetX(spriteX);

Sprites[spriteIndex].SetY(spriteY);

Sprites[spriteIndex].SetColor(color);

App.Draw(Sprites[spriteIndex]);
}

Above code compiles and links with zero warnings and zero errors...

Any ideas on how to make this work?
(code is from a C++ Class called "Visuals")