Wiki

Clone wiki

Fairlight / SceneManager and Scenes

Introduction

In most games you'll require various states, like Title-Screen, Game, Game-Over-Screen. For easy management of those states Fairlight offers you an easy to use State-Machine. States are called Scenes, the StateMachine itself is called SceneManager.

Scenes

Derive your Scenes from fairlight.src.statemachine.scene. Then add at least an OnEnter and OnLeave Method, for example to load resources like images and sounds and to finally clean memory up.

You can also implement other Interfaces if you'd like to. When you switch between scenes the SceneManager is responsible that the scene itself get registered at the required EventHandlers (if you have registered an EventManager).

SceneManager

The SceneManager is responsible for managing all scenes, so you have to add all Scenes you'd like to use.

Example

You'll find a simple example that should explain the concepts at examples/statemachine.

Updated