That is exactly what the
StateStack class's delayed push and pop mechanism is for. Inside a state
update(), you are given three methods to control the execution and transitions of states:
It is appropriate to use these methods to request new states to be pushed, or to show and replace the current one, as you will verify that our example states do throughout this chapter.
So far we have covered the theory and practice for inserting the state stack into our sample game. It is fully functional but yet empty, so, it is finally time to create our first state, the game state.
For this, we create a class named
GameState and we proceed to relocate the code that could be found in the...