SFML community forums

General => Feature requests => Topic started by: SeriousITGuy on July 04, 2014, 10:17:17 am

Title: Can sf::Transformable have a alignOrigin function?
Post by: SeriousITGuy on July 04, 2014, 10:17:17 am
Hi there,

in my recent projects experimenting with 2D Game Engines, I always end up writing utility-functions for aligning the origin of sfml objects like sf::Text, sf::Shape and sf::Sprite relatively to the sprite size, like e.g set the origin to the center, or Top-Right, Bottom-Left etc.

Here's my reference code (https://github.com/SeriousITGuy/Ion-Tech-2/blob/master/src/ion/Utility.cpp)

Centering the origin relatively to the entity size is very often used, and I use the other relative alignments for displaying GUI-Objects. It would come in really handy if sf::Transformable would have an abstract function alignOrigin( Alignment align) which then gets implemented by the child classes like shape, text etc., and if one designs his own entities with sf::Transformable, he could implement it for his own classes.

So accompanying sf::Transformable::setOrigin for setting the absolut origin, a alignOrigin for setting the relative origin would be a valuable addition in my opinion.

Thanks in advance!