SFML community forums

Help => General => Topic started by: Elfinity on March 25, 2011, 07:22:55 pm

Title: Pivot point
Post by: Elfinity on March 25, 2011, 07:22:55 pm
(http://img27.imageshack.us/img27/7317/pivotc.png) (http://img27.imageshack.us/i/pivotc.png/)

Uploaded with ImageShack.us (http://imageshack.us)
Code: [Select]
sf::Vector2f mTP = sf::Vector2f(WMain.GetInput().GetMouseX()-tTurrTankS.GetPosition().x,WMain.GetInput().GetMouseY()-tTurrTankS.GetPosition().y);
float fAngle = atan(mTP.x/mTP.y);
if(mTP.x == 0 && mTP.y == 0)
fAngle = 0;
fAngle *= 180/3.14159;
if(mTP.y >= 0)
fAngle += 180;

tTurrTankS.SetRotation(fAngle);

This is the code I use but,the Turrent rotates like it's center is somewhere else.
Title: Pivot point
Post by: Lupinius on March 25, 2011, 09:52:15 pm
You can set the pivot point with SsetCenter (SFML 1.6) org SetOrigin (SFML 2.0).