Quote:Original post by ncsu121978
What should I do ?
You could provide a virtual bool should_render_parent() const method so each state can decide whether the state beneath it should be rendered prior to rendering itself.
Whole-screen states like start screen mode or game mode would return false, options menu would return true, other modes could return different values depending on context etc?
Personally I've given up using a stack of game states - unless you are writing something like an RPG with heavily nested menus or screens, I think it is overkill. I use a similar interface to yours but just have a single std::auto_ptr<BaseMode> that contains a pointer to the current mode. I just switch between modes in response to game events, so when the game is running, the start screen and all its resources are automatically destroyed etc. Assigning a new start screen pointer to the std::auto_ptr automatically destroys all the game state resources etc. Things like options menus are handled as a special case.
Depends on the application though.