1
Graphics / Rotate Sprite
« on: July 02, 2009, 10:01:27 am »
Now I have:
but still doesn't work properly. The same story :/
EDIT:
Success! It must look like this:
Thanks for help!
Code: [Select]
Sprite.SetCenter(Sprite.GetSize() / 2.f);
if (App.GetInput().GetMouseX() <= Sprite.GetPosition().x) {
Sprite.SetRotation (-1* 360 / 3.1415926535 * (atan2( static_cast<double> (Sprite.GetPosition().y - App.GetInput().GetMouseY()) , static_cast<double> (Sprite.GetPosition().x - App.GetInput().GetMouseX()))));
} else {
Sprite.SetRotation (-1* 360 / 3.1415926535 *(atan2( static_cast<double> (Sprite.GetPosition().y - App.GetInput().GetMouseY()) , static_cast<double> (Sprite.GetPosition().x - App.GetInput().GetMouseX()))));
}
App.ConvertCoords(App.GetInput().GetMouseX(), App.GetInput().GetMouseY());
but still doesn't work properly. The same story :/
EDIT:
Success! It must look like this:
Code: [Select]
Sprite.SetCenter(Sprite.GetSize() / 2.f);
if (App.GetInput().GetMouseX() <= Sprite.GetPosition().x) {
Sprite.SetRotation (((-1* 360 / 3.1415926535 * (atan2( static_cast<double> (Sprite.GetPosition().y - App.GetInput().GetMouseY()) , static_cast<double> (Sprite.GetPosition().x - App.GetInput().GetMouseX()))))/2)+90);
} else {
Sprite.SetRotation (((-1* 360 / 3.1415926535 *(atan2( static_cast<double> (Sprite.GetPosition().y - App.GetInput().GetMouseY()) , static_cast<double> (Sprite.GetPosition().x - App.GetInput().GetMouseX()))))/2)+90);
}
Thanks for help!