class GameState //abstract class gamestates are derived from{ public: virtual function() = 0; virtual run() = 0; //etc};
class GameState;class GameStateManager{ void push_state(); void pop_state(); etc private: vector<GameState*> stateList;};
My question then is, how would you go about letting individual states communicate with each other? For example, play is pressed in the menu and then a playing state should be pushed onto the vector (stack). Possible solutions I can think of are making the Manager a singleton(I don't really want to do that) or adding a return type on the run function that will then notify the manager as to what should be pushed / popped.
I'm really just looking for opinions here. Are there any downsides to just returning an int type / gamestate from the run function and then letting the manager run them through a switch?
Thanks.