I'm very new to SFML, so please be gentle,
I have a Particle class that I want to make drawable, so I want it to inherit sf::Drawable and override the draw function so that I can use window.draw(myClass). However, when I try to instantiate a particle from the class, Visual Studio tells me that "pure virtual function "sf::Drawable::draw" has no overrider" even though I've followed everything the docs said. I've dug through some similar questions on this forum already, as well as a couple of stackoverflow questions, and nothing has helped - either I've already done whatever the response suggests doing or the original asker didn't have the same problem as me.
Here's the relevant part of Particle.cpp:
void Particle::draw(sf::RenderWindow& window, sf::RenderStates states) const {
window.draw(body);
}
Here's Particle.h:
class Particle : public sf::Drawable {
public:
void update();
void show();
Particle();
float getMass();
private:
float x;
float y;
float radius;
sf::CircleShape body;
void draw(sf::RenderWindow& window, sf::RenderStates states) const;
};
and here's the relevant part of main.cpp:
sf::RenderWindow window(sf::VideoMode(800, 800), "qinetiq");
Particle particle1 = Particle();
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
}
window.clear(sf::Color::Black);
window.draw(particle1);
Any and all help is massively appreciated, this is my first post on this forum, so if I'm doing something wrong please let me know.