SFML community forums

Bindings - other languages => D => Topic started by: joelcnz on February 02, 2016, 05:48:26 am

Title: Rotate with a set pivot point, and get rotation
Post by: joelcnz 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);.
Title: Re: Rotate with a set pivot point, and get rotation
Post by: Hapax 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() (http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1Transformable.php#af8a5ffddc0d93f238fee3bf8efe1ebda)
(or setRotation() in conjunction with getRotation())

(click to show/hide)
Title: Re: Rotate with a set pivot point, and get rotation
Post by: joelcnz 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.
Title: Re: Rotate with a set pivot point, and get rotation
Post by: Hapax 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);
Title: Re: Rotate with a set pivot point, and get rotation
Post by: joelcnz on February 08, 2016, 08:00:43 am
Thanks Hapax.  :) I should've known the rotation thing.