All examples · Scenes

First scene

What this example shows

The anatomy of every scene, spread over three files. index.ts creates the game with the scenes it knows, by name. scenes/game_scene.ts is the scene: a function that runs once. And entities/player.ts is the player.

The player is not a special kind of thing: it is an ordinary function called from the scene body, so what it creates (the sprite) and what it registers (its useUpdate) belong to that scene. A game is built this way, from small pieces that can move from one file to another.

Starting