The current stack manager does not allow for Heads-Up-Display overlays yet, as each time a new state is pushed to the
stack, the previous state is paused. We therefor have to add the possibility to overlay states over each other.
The Stack
Overlaying States
To add a new overlay, we simply push the new state to the stack:
Pushing States
Now when pushing a new state to the stack, we have to pause all underlying states:
Popping States
When popping a state from the stack, we have to resume all underlying states:
A Barebone HUD
I created a blank HUD state that simply writes its name to the bottom of the screen. The main playState then
initializes its own HUD:
And that’s it. Our Stack Manager now supports HUDs.
This concludes our first series of tutorials about state stacks. You can download the source code
from here.