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

Author Topic: Can sf::Transformable have a alignOrigin function?  (Read 3757 times)

0 Members and 1 Guest are viewing this topic.

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Can sf::Transformable have a alignOrigin function?
« 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

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!