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

Author Topic: To inherit or not?  (Read 754 times)

0 Members and 1 Guest are viewing this topic.

intrinsic

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
To inherit or not?
« 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
AW: To inherit or not?
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything