SFML community forums

Help => General => Topic started by: intrinsic on August 25, 2016, 05:20:12 am

Title: To inherit or not?
Post by: intrinsic on August 25, 2016, 05:20:12 am
So I'm not sure if my MapTile and BrushTile classes should inherit from the sf::Sprite class.
From what I've read it depends on the relationship. With a HAS_A relationship you would simply add the sprite as member. But if it's a IS_A relationship, you would tell your class to inherit from the other.

I hope I'm making sense, could some one please clarify the rules.
Title: AW: To inherit or not?
Post by: eXpl0it3r on August 25, 2016, 09:26:07 am
Your tile is most likely not directly a sprite in the sense that you want your tiles to share the full sprite interface (setTexture, getGlobalBounds, etc.).
What you most likely want to do instead, is to derive from sf::Drawable and optionally from sf::Transformable and then use a sprite internally.