Class: ScreenManager
The `ScreenManager` class is a singleton responsible for manages a stack of screens.
Nota bene: requestPush, requestSet and requestPop are all asynchronously method and will be
executed safely in the update loop.
Constructors
- new ScreenManager(): ScreenManager
The constructor.
Methods
- draw(): void
The "draw" function.
- requestPopScreen(): void
The "requestPopScreen" function pops the top screen from the screen stack.
Nota bene: it call the `onExit` virtual method on the popped screen.
- requestPushScreen(newScreen: Screen, args: any): void
The "requestPushScreen" function pushes a new screen to the stack, throwing an error if the
screen is already present.
Nota bene: it call `onEnter` virtual method on the new screen.
- newScreen: The new screen that you want to push onto the stack.
- args: args is an optional parameter of type any. It is used to pass additional
arguments to the new screen when it is being pushed onto the stack. The default value is an empty
object ({}).
- requestSetScreen(newScreen: Screen, args: any): void
The "requestSetScreen" function remove all screens and sets a unique new screen to the stack.
Nota bene: it call the `onEnter` virtual method on the new screen.
- newScreen: The new screen that you want to set as the current screen.
- args: The `args` parameter is an optional object that can be passed to the `onEnter`
method of the `newScreen` object. It allows you to pass any additional data or configuration that
the `newScreen` may need when it is being entered.
- update(ts: number): void
The "update" function.
- ts: The `ts` parameter stands for "timestep".