I am building a app that consists of 20 mini games. Each one will inherit from the base class ‘game’ and have some common functionality. I am trying to store all games in a vector so I can access them with games[currentIndex]
In ofApp.h I have
vector<game*> games;
In ofApp.cpp
games.push_back(new gameHula());
games.push_back(new gameSkate());
...
for (int i = 0; i < 20; i++) {
games[i]->setup();
}
game.h
class game{
public:
void setup();
void update();
void draw();
gameSkate.h
class gameSkate : public game{
public:
void setup();
void update();
void draw();
The problem is that when setup is called it only runs on the base class and not on gameHula or gameSkate. How can I make it so the child class setup is called first followed by the parent?