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

Author Topic: Maths and Rotations  (Read 2055 times)

0 Members and 1 Guest are viewing this topic.

fabvman

  • Newbie
  • *
  • Posts: 11
    • View Profile
Maths and Rotations
« on: August 20, 2011, 07:23:38 am »
Hello. I'm using SFML 1.6 and I am having problems trying to rotate a sprite because the axis of rotation is located in the upper left corner. How could I rotate the sprite with an axis of rotation located at the center of the sprite without changing permanently the center of the sprite? All the logic of my code is based on the sprite's center located in the upper left corner and I wondered if there was any alternative to perform this rotation without using SetCenter () at the beginning of the code, perhaps with some maths and sprite->Move (). I tried the following:

sprite->SetCenter(sprite-> GetSize (). x / 2.0f, sprite-> GetSize ().y / 2.0f);
sprite->Rotate (angle);
sprite->SetCenter (0, 0);

It does not work because the sprite moves when I move the center, resulting in the sprite rotates around its upper left corner.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Maths and Rotations
« Reply #1 on: August 20, 2011, 09:26:46 am »
There's no solution, SFML provides a simple but sometimes too limited API.
Laurent Gomila - SFML developer

fabvman

  • Newbie
  • *
  • Posts: 11
    • View Profile
Maths and Rotations
« Reply #2 on: August 26, 2011, 06:29:52 am »
That is only a small problem, SFML is really great.

Cpl.Bator

  • Hero Member
  • *****
  • Posts: 540
    • View Profile
Maths and Rotations
« Reply #3 on: August 26, 2011, 10:44:04 am »
Quote
It does not work because the sprite moves when I move the center, resulting in the sprite rotates around its upper left corner.


Substract half center by sprite position , no ?