SFML community forums
Help => Graphics => Topic started by: Romans on November 02, 2019, 05:31:08 pm
-
Hello! I'm watching this example into SFML VertexArray Examples (the last in the bot: the Particle System):
https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php
I'm trying to use it and it's very good but i have some question, and the most important of them is:
What is the method virtual void draw(RenderTarget, RenderStates), where did they use it?
How does it works? If i remove the function, it gives the error:
particles.cpp|88|error: cannot declare variable 'particles' to be of abstract type 'ParticleSystem'
At the main where it creates the class instance. WHy? Thank you
-
The draw function is a function in the base class of sf::Drawable, from which, as you can see, ParticleSystem is derived.
This allows ParticleSystem to be drawn in a similar way to other SFML drawables. Namely, window.draw(object) rather than object.draw(window).
It talks about this in the very tutorial you mentioned but more specifically in the Creating an SFML-like entity (https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php#creating-an-sfml-like-entity) section.