Skip to content

Documentation / @debuffjp/ui / Transition

Class: Transition ​

Defined in: transition.ts:22

A fade-out → swap → fade-in screen transition. run(swap) covers the screen, calls swap once fully covered (move the player, load the level, change scene), then uncovers it. Driven by update(dt), so it stays deterministic under replays and scenarios.

ts
const fade = new Transition({ color: "#1a1020" });
fade.run(() => placePlayer(stairs));
// every step: fade.update(dt); if (fade.blocking) return;
// after drawing the world: fade.draw(draw, 0, 0, game.width, game.height);

Constructors ​

Constructor ​

new Transition(options?): Transition

Defined in: transition.ts:28

Parameters ​

options? ​

TransitionOptions = {}

Returns ​

Transition

Properties ​

color ​

color: string | number

Defined in: transition.ts:24


duration ​

duration: number

Defined in: transition.ts:23

Accessors ​

active ​

Get Signature ​

get active(): boolean

Defined in: transition.ts:48

A transition is running.

Returns ​

boolean


blocking ​

Get Signature ​

get blocking(): boolean

Defined in: transition.ts:53

Still covering or swapping: gameplay usually pauses until the fade-in starts.

Returns ​

boolean


cover ​

Get Signature ​

get cover(): number

Defined in: transition.ts:58

How covered the screen is, 0 to 1.

Returns ​

number

Methods ​

draw() ​

draw(draw, x, y, w, h): void

Defined in: transition.ts:76

Draw the cover over a region (usually the whole screen, or the play area below a HUD).

Parameters ​

draw ​

DrawLike

x ​

number

y ​

number

w ​

number

h ​

number

Returns ​

void


inspect() ​

inspect(): object

Defined in: transition.ts:85

Returns ​

object

active ​

active: boolean

cover ​

cover: number


run() ​

run(swap?): boolean

Defined in: transition.ts:34

Start a transition. Ignored while one is already running, so a held button can't stack them.

Parameters ​

swap? ​

() => void

Returns ​

boolean


stop() ​

stop(): void

Defined in: transition.ts:42

Cancel without calling the pending swap, e.g. on a full reset.

Returns ​

void


update() ​

update(dt): void

Defined in: transition.ts:63

Parameters ​

dt ​

number

Returns ​

void