ScreenFade

A full-screen colour overlay drawn on top of the game and its UI, faded in or out over time. Game owns one (game.screenFade) and drives it for Game.changeSceneWithFade(); you can also call fadeTo() on it directly, e.g. to dim the screen behind a pause menu.

Properties

  • color (integer) — Overlay colour, packed RGB (0xRRGGBB)
  • opacity (float) — 0 = invisible, 1 = fully covers the screen

Constructor

new ScreenFade(): ScreenFade

Instance Methods

fadeTo(targetOpacity: float, seconds: float): void

Starts fading from the current opacity to the given one.

Parameters

  • targetOpacity (float) — 0 (clear) to 1 (fully covered)
  • seconds (float) — how long the fade takes; 0 or less jumps straight there

Returns

  • void

isFading(): boolean

Whether a fade is in progress.

Returns

  • boolean

tick(dt: float): boolean

Advances the fade. Called by Game once per frame.

Parameters

  • dt (float) — seconds since last frame

Returns

  • boolean — true on the frame the fade finishes

draw(uiRenderer: Renderer): void

Draws the overlay, if visible. Called by Game after the UI is drawn.

Parameters

Returns

  • void