Exactly how do I call the sf::Sprite::draw()?
I have:
class MyClass : public sf::Sprite {
private:
void draw(sf::RenderTarget& target, sf::RenderStates states) const {
// My functionality
sf::Sprite::draw(target, states); // Yields compiler error due to member being inaccessible
sf::Drawable::draw(target, states); // Yields linker error
}
}
So how do I do it the correct way? o:
It would be cleaner to have a class that's Drawable and has a Sprite (composition):
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderStates.hpp>
class MyClass : public sf::Drawable {
private:
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const {
// My functionality
target.draw(sprite, states);
}
private:
sf::Sprite sprite;
};