I noticed sf::Drawable's draw(...) method is protected. Why is that? (I'm not the best C++ programmer, so pardon me if the answer's rather obvious.)
As a followup question, what is the best way to call this method from outside my implementing class, StateMenu?
Here's my parent interface:
// a state the game can be in (menu, playing, credits).
class State : public EventHandler, public sf::Drawable {
public:
virtual void update(const sf::Time &delta) = 0;
};
Here's an implementer of that interface:
// the title menu of the game.
class StateMenu : public State {
public:
bool handleEvent(sf::Event &event);
void update(const sf::Time &delta);
void draw(sf::RenderTarget &target, sf::RenderStates states) const;
private:
sf::Time mTimeElapsed;
};
And here's some snippets from main.cpp:
sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), TITLE,
sf::Style::Titlebar | sf::Style::Close);
State *state;
void render() {
window.clear(sf::Color::Black);
state->draw(window, sf::RenderStates::Default);
window.display();
}
int main() {
...
state = new StateMenu;
...
while (window.isOpen()) {
...
render();
}
return 0;
}
Sorry if I posted too much code, and thanks in advance for any and all help!