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

Author Topic: Apply a View to a Transformable  (Read 1542 times)

0 Members and 1 Guest are viewing this topic.

Dincio

  • Newbie
  • *
  • Posts: 13
    • View Profile
Apply a View to a Transformable
« on: March 03, 2017, 11:23:56 pm »
Hello  ;D

I'm coding up a GUI library for sfml and I'm trying to make it work along with views and viewports.

Basically, I want an object of type Interface, which inherits from Transformable, to accept a view and then draw itself relative to that view.

Unfortunately, I can't seem to find a way to implement all of this... I've tried getting the transformation of the view with getTransform() and apply it to the transformation element of states before drawing, but it didn't work as I expected it too...

Thanks in advance for any help.

sjaustirni

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Re: Apply a View to a Transformable
« Reply #1 on: March 04, 2017, 11:12:43 am »
Composition over inheritance

The simplest thing here is to have your GUIElement (or whatever it is called) contain sf::Transformable and sf::Drawable and then draw it like this:
window.draw(drawable, transformable);

See this for more info.

 

anything