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

Author Topic: SFML Game Development Chapter 3 question  (Read 902 times)

0 Members and 1 Guest are viewing this topic.

Zeleska

  • Newbie
  • *
  • Posts: 5
    • View Profile
SFML Game Development Chapter 3 question
« on: April 18, 2019, 05:01:18 am »
I don't understand: why in the class SceneNode the member function drawCurrent() is empty, but it seems it has functionality.
The book says (page 58):
Quote
We also provide a new virtual function drawCurrent() which only draws the current object (but not the children).

The function definition is (in the GitHub https://github.com/SFML/SFML-Game-Development-Book/blob/master/03_World/Source/SceneNode.cpp):
void SceneNode::drawCurrent(sf::RenderTarget&, sf::RenderStates) const
{

        // Do nothing by default

}

Also, this is quite the chapter haha.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: SFML Game Development Chapter 3 question
« Reply #1 on: April 18, 2019, 07:49:43 am »
I haven't read the book, but most likely derived classes will override it and put something meaningful inside. The base class, an abstract scene node, has nothing to draw itself.
Laurent Gomila - SFML developer

Zeleska

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML Game Development Chapter 3 question
« Reply #2 on: April 19, 2019, 08:21:21 pm »
It's just as you say!, it was meant to be override by derived classes. What happened is that I stopped reading the moment I saw the "empty functionality", instead of keep reading...
Thanks for replying, and thank you and others for the library.