SFML community forums

Help => General => Topic started by: Zeleska on April 18, 2019, 05:01:18 am

Title: SFML Game Development Chapter 3 question
Post by: Zeleska 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.
Title: Re: SFML Game Development Chapter 3 question
Post by: Laurent 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.
Title: Re: SFML Game Development Chapter 3 question
Post by: Zeleska 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.