Hello
I'm following the "SFML Game Development" book from Packt, in its example it creates a scenenode class that inherits from sf::Drawable.. that's good, as I understand it serves to draw my scenenode as simply typing
myRenderWindow.draw(mySceneNode);
it has so much sense..!
but then, there is a spritenode class that inherits from scenenode class... but spritenode has a sf::Sprite property..
when i try to draw mySpriteNode object, the build is success.. but nothing shows on the screen...
but when i draw mySpriteNode.m_sprite (assuming m_sprite is public), then the sprite shows on the screen...
is this the expected behaviour ?...
I haven't read that book, but I'm guessing how they've probably structured it.
The scene node class must have a draw method, so the myRenderWindow.draw(mySceneNode); works.
If you make new kinds of scene nodes (like a sprite node), they need their own draw method that overrides (replaces) the scene node draw method.
So in your sprite node class you'd need something like:
void SpriteNode::draw(RenderTarget& target, RenderStates states) const
{
target.draw(m_sprite);
}
So when you tell the sprite node to draw, it in turn tells the sprite member to draw.
Is that function there? Make sure it's name and parameters are identical to the one in scene node (if you called it Draw instead of draw it will call the wrong one).