Scenes
Dill Pixel uses a scene management system to manage different scenes
in your game. For example, a simple game might have Title
, Game
, and GameOver
scenes.
Let’s see how we would include those in our game and switch between them.
Creating a Base Scene
To create a new scene, create a new file in the src/scenes
directory. For example, let’s create a BaseScene
that all of our other game scenes will extend. This first scene should extend dill pixel’s Scene
class
and for now we’ll just add custom animateIn
and animateOut
methods that will fade all of our scenes in and out:
Creating a Scene
Next, let’s create a StartScene
that extends our BaseScene
:
Configuring Scenes
Scenes in the ./src/scenes directory will be automatically registered with the game.
You can configure how your scene is loaded by modifying a few custom exports in your scene file:
Switching Between Scenes
To switch between scenes, use the transitionTo
method on the game instance: