Skip to main content
  1. 📝 Notes/
  2. Firefly Devlog/

Screen Manager

devlog - This article is part of a series.
Part 9: This Article

I needed a more robust way to switch Screens. At this point in time I have three different screens:

  • Start Screen
  • Game Screen
  • Result Screen (shown when Game Over)

Switching to those screens worked via a global variable. Game starts? var screen string = "start". Enter the game? screen = "game"… You get the idea.

The problem with this approach: it is surprisingly hard to keep track about what screen is supposed to be shown. This gets messy pretty soon, especially when those screens are stateful.

So I “invented” a ScreenManager logic, to register screens at startup and set the right screen when desired. This not only makes intent way more obvious, but it also allows for some screen-lifecycle. I can now react OnEnter() or OnExit(), e.g. for loading/unloading assets. This structure would even be sufficient if I later want to implement a “back” functionality. If anyone is interested, I created a barebones PoC here.

Change: oozwpxwk

Creating a Settings Screen
#

Now that I have something to switch screens, I started working on a settings screen. This will be the screen to view or edit configurations.

Not exceptionally beautiful or even exciting. But it works and does what it is supposed to do. Everything design related is anyways a task on its own, that I successfully procrastinate…

Change: lkmypylt



devlog - This article is part of a series.
Part 9: This Article
Christoph Voigt
Author
Christoph Voigt
A little bit about you