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

Author Topic: Quick resources question  (Read 1493 times)

0 Members and 1 Guest are viewing this topic.

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Quick resources question
« on: January 21, 2018, 05:48:36 pm »
I have a base class Panel and various derived classes like PlayerPanel.

Currently the base class holds an sf::Texture* and I assign them from my Interface class like objPlayerPanel.texPanel = &texInterface. I do this many times for each derived panel.

After completing the UI, it seems that all the derived panels will use the same texture file. Originally I thought I might have different files for different panels, but that didn't turn out to be the case.

Should I keep the code as it is, or should I instantiate the base class and let it load the texture?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Quick resources question
« Reply #1 on: January 21, 2018, 06:01:46 pm »
If something is shared among all derived classes, it's probably better to have it in the base class.

But as always, the real answer is: It depends... ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything