Navigating between states
So far we have our state machine in place and running smoothly, the title screen starts up the program, but how to make the title screen call another state to its place when someone hits a key?
That is exactly what the StateStack
class's delayed push and pop mechanism is for. Inside a state handleEvent()
and update()
, you are given three methods to control the execution and transitions of states: requestStackPush()
, requestStackPop()
, and requestStackClear()
.
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.
Creating the game state
So far we have covered the theory and practice for inserting ...
Get SFML Game Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.