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

Author Topic: Multiple inheritance of RectangleShape and Text, no longer a child of Drawable  (Read 2135 times)

0 Members and 1 Guest are viewing this topic.

MediocreVeg1

  • Newbie
  • *
  • Posts: 9
    • View Profile
Hi, sorry for posting again so quickly, but I'm having an issue with multiple inheritance of sf::RectangleShape and sf::Text.
The reason I'm doing this is because I need to implement textboxes and I'd prefer to use inheritance over encapsulation (in which case the rectangle and text would be separate private objects) since i have also used inheritance for my player, NPCs and tile maps. However, when I try to draw this, I get the following error:
‘sf::Drawable’ is an ambiguous base of ‘Textbox’
Here is my Textbox constructor (where i also draw the textbox) in case you need it.
Textbox::Textbox(sf::Vector2f position, sf::Vector2f dimensions, std::vector<std::string> text, sf::RenderWindow& window)
{
    RectangleShape::setPosition(position);
    Text::setPosition(position.x + 3, position.y + 6);
    if (!font.loadFromFile("assets/DeterminationMono.ttf"))
        exit(1);
    Text::setFont(font);

    for (std::string i : text)
    {
        Text::setString(i);
        window.draw(*this);
    }
}
 

Once again, it's pretty late at night here, so I may respond in some hours :)
« Last Edit: December 21, 2020, 08:03:59 pm by MediocreVeg1 »

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
probably the same answers I got here  :P
https://en.sfml-dev.org/forums/index.php?topic=27556.0
Visit my game site (and hopefully help funding it? )
Website | IndieDB

MediocreVeg1

  • Newbie
  • *
  • Posts: 9
    • View Profile
Hmm, I guess I'll just have to deal with encapsulation then, but thanks for the reply  :D

 

anything