Beep8 logo

Scene Documentation

Scene Documentation Source Code

Scene Methods

beep8.Scene.add(name, gameObject)

Adds a new scene to the scene manager.

A scene should be a javascript object with at least one of the following functions:

  • init (optional): A function that will be called when the scene is set.
  • update (optional): A function that will be called multiple times a frame and passed a deltatime value as a parameter.
  • render (optional): A function that will be called every frame.

Init can be used to set up the scene. For asynchronous games you can add a while loop here and use await functions (eg for keypresses) and then render yourself. For synchronous games you can use the update and render functions to manage game logic and rendering efficiently.

eg: const game = { init: () => { } update: ( dt ) => { } render: () => { } }

Parameters

  • name (string): The name of the scene.
  • gameObject (object): An object that includes init, update, and

beep8.Scene.get()

Gets the current active scene.

Returns

  • (Object|null): The active scene object, or null if no scene is active.

beep8.Scene.getAll()

Gets all scenes.

Returns

  • (Object): All scenes.

beep8.Scene.pause(name)

Pauses the current scene.

Parameters

  • name (string): The name of the scene to pause.

beep8.Scene.resume()

Resumes the current scene.

beep8.Scene.set()

Switches to a specified scene by name.

More Beep8 Docs

Actors Documentation

Async Documentation

Core Functions

Input Documentation

App Intro Documentation

Joystick Documentation

Menu Documentation

Music Documentation

Particle System Documentation

Passcodes Documentation

Public API

Random Numbers Documentation

Scene Documentation

SFX Documentation

Text Renderer

Tilemap Documentation

Utilities Documentation