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

Author Topic: Rotate with a set pivot point, and get rotation  (Read 13667 times)

0 Members and 1 Guest are viewing this topic.

joelcnz

  • Newbie
  • *
  • Posts: 17
    • View Profile
    • Email
Rotate with a set pivot point, and get rotation
« on: February 02, 2016, 05:48:26 am »
SFML doesn't seem to have a pivot setting. I want to rotate a sprite from its centre.

Also, how do you do relative rotation on a sprite? Only one kind of rotation works - object.rotation(90);.
« Last Edit: February 02, 2016, 06:21:17 am by joelcnz »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Rotate with a set pivot point, and get rotation
« Reply #1 on: February 02, 2016, 06:44:18 am »
SFML doesn't seem to have a pivot setting. I want to rotate a sprite from its centre.
It does:
http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1Transformable.php#aa93a835ffbf3bee2098dfbbc695a7f05

Also, how do you do relative rotation on a sprite? Only one kind of rotation works - object.rotation(90);.
Relative rotations can be done with rotate()
(or setRotation() in conjunction with getRotation())

(click to show/hide)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

joelcnz

  • Newbie
  • *
  • Posts: 17
    • View Profile
    • Email
Re: Rotate with a set pivot point, and get rotation
« Reply #2 on: February 02, 2016, 07:35:55 am »
Thanks for the help with sprite origin for rotating.

These 2 below don't work for me (using D):
rotate(10);
sprite.setRotation(sprite.getRotation() + 90);

sprite.rotation(90); works instead of sprite.setRotation(90); for me.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Rotate with a set pivot point, and get rotation
« Reply #3 on: February 03, 2016, 08:37:20 am »
Sorry. I didn't notice that this was posted in a D binding forum.

I didn't realise that the commands were that different:
http://jebbs.github.io/DSFML/dsfml/graphics/transformable.html

I'm not sure how to get the current rotation but it looks like it might be something like:
sprite.rotation(sprite.rotation() + 10);
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

joelcnz

  • Newbie
  • *
  • Posts: 17
    • View Profile
    • Email
Re: Rotate with a set pivot point, and get rotation
« Reply #4 on: February 08, 2016, 08:00:43 am »
Thanks Hapax.  :) I should've known the rotation thing.

 

anything