Molten

.screen files

One screen per file in screens/. The screen's name is the file name in PascalCase: screens/game_over.screen is GameOver.

// samples/gridline/screens/main_menu.screen
export default screen({ level: "menu", ui: ["ui/menu"] });
Key Type Default Meaning
level string or null null The level switchScreen loads for this screen; null unloads the current level
ui array of strings [] UI files shown while the screen is on the stack, relative to the game root; .ui optional
logic string A Cast module path relative to this file, including .cast

Errors

Message Cause
unknown level 'yards' No levels/yards/
unknown UI file 'ui/pause' No ui/pause.ui
level must be a string or null
unknown key 'k' (allowed keys: level, ui, logic)

Behavior

  • switchScreen loads the screen's level every time, even if it is already loaded.
  • pushScreen never changes the level. A pushed screen whose level isn't null logs a warning.
  • Saving a .screen file while it is active applies the change (for example a new UI list or a different level) without leaving and re-entering the screen.

The logic module must export at least one callback:

Export Timing
onEnter(): void When the screen is switched to or pushed, after level load
onExit(): void When the screen is popped or switched away, before level unload
update(dt: float): void Once per fixed tick while this screen is on top. dt is in seconds

Popping an overlay resumes updates on the screen beneath it. Its onEnter runs only when it joins the stack.

View this page's source on GitHub