Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Pivot point  (Read 1622 times)

0 Members and 1 Guest are viewing this topic.

Elfinity

  • Newbie
  • *
  • Posts: 3
    • View Profile
Pivot point
« on: March 25, 2011, 07:22:55 pm »


Uploaded with 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.

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Pivot point
« Reply #1 on: March 25, 2011, 09:52:15 pm »
You can set the pivot point with SsetCenter (SFML 1.6) org SetOrigin (SFML 2.0).