Skip to content

API Class SubtitleDisplay

github-actions[bot] edited this page Nov 29, 2026 · 6 revisions

Class: SubtitleDisplay

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:49

A user script. Subclass it, implement lifecycle methods, and attach it to nodes.

@behavior("game.Spinner")
export class Spinner extends GameBehavior {
  @field(Number) speed = 90;
  update() { this.transform.rotation2D += this.speed * Time.deltaTime; }
}

Extends

Constructors

Constructor

new SubtitleDisplay(): SubtitleDisplay;

Returns

SubtitleDisplay

Inherited from

GameBehavior.constructor

Properties

captions

captions: boolean = true;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:70

Shows captions when the player's setting allows.


component

component: string = "";

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:51

A Svelte component replacing the built-in one; it gets the rows and their placement as props (see the class's notes).


fadeIn

fadeIn: number = 0.12;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:66

Seconds.


fadeOut

fadeOut: number = 0.2;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:68

Seconds.


margin

margin: number = 8;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:54

% of the canvas height from the edge (title-safe).


maxLines

maxLines: number = 2;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:58

Lines per page before paging.


maxStack

maxStack: number = 3;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:60

Rows on screen at once.


maxWidth

maxWidth: number = 70;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:56

% of the canvas width.


position

position: "top" | "bottom" = "bottom";

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:52


sizeScale

sizeScale: number = 1;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:62

Multiplies the size presets.


speakerNames

speakerNames: SpeakerNameMode = "always";

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:64

always, whenSeveral (only while two or more speakers are shown) or never.


executionOrder

static executionOrder: number = 0;

Defined in: src/engine/core/Component.ts:263

Lower values run earlier within the same hook.

Inherited from

GameBehavior.executionOrder

Accessors

abortSignal

Get Signature

get abortSignal(): AbortSignal;

Defined in: src/engine/core/Component.ts:284

Aborted when this behavior is disabled or destroyed. Use it for fetch and other non-engine async work.

Returns

AbortSignal

Inherited from

GameBehavior.abortSignal


enabled

Get Signature

get enabled(): boolean;

Defined in: src/engine/core/Component.ts:62

Returns

boolean

Set Signature

set enabled(value): void;

Defined in: src/engine/core/Component.ts:66

Parameters
value

boolean

Returns

void

Inherited from

GameBehavior.enabled


gameObject

Get Signature

get gameObject(): GameObject;

Defined in: src/engine/core/Component.ts:42

Unity-style alias for node.

Returns

GameObject

Inherited from

GameBehavior.gameObject


input

Get Signature

get input(): BehaviorInput;

Defined in: src/engine/core/Component.ts:278

The input of the player controlling this behavior's node (ADR 0336, 0337): the pawn's actions (the nearest node up with ControlledBy or an action set), else player 0's. this.input.vector2("move"), this.input.performed("jump"), this.input.on("heavy", "performed", fn).

Returns

BehaviorInput

Inherited from

GameBehavior.input


isActiveAndEnabled

Get Signature

get isActiveAndEnabled(): boolean;

Defined in: src/engine/core/Component.ts:73

True when enabled, the node is active in the hierarchy, and the node is in a loaded world.

Returns

boolean

Inherited from

GameBehavior.isActiveAndEnabled


node

Get Signature

get node(): GameObject;

Defined in: src/engine/core/Component.ts:37

The node this component is on.

Returns

GameObject

Inherited from

GameBehavior.node


owner

Get Signature

get owner(): GameObject;

Defined in: src/engine/core/Component.ts:50

The node this component acts for: the node itself when attached directly, or the parent node when this component lives on a component node (ADR 0009).

Returns

GameObject

Inherited from

GameBehavior.owner


time

Get Signature

get time(): Readonly<TimeState>;

Defined in: src/engine/core/Component.ts:98

This component's World's clock (ADR 0032): the same values as Time, but safe to read outside the World's frame too (after an await, say).

Returns

Readonly<TimeState>

Inherited from

GameBehavior.time


transform

Get Signature

get transform(): Transform;

Defined in: src/engine/core/Component.ts:56

The Transform of the node this component is on, if it has one.

Returns

Transform

Inherited from

GameBehavior.transform


wait

Get Signature

get wait(): Waits;

Defined in: src/engine/core/Component.ts:269

Engine-scheduled waits that respect pause and time scale, cancelled on disable/destroy (ADR 0018).

Returns

Waits

Inherited from

GameBehavior.wait


world

Get Signature

get world(): WorldHandle;

Defined in: src/engine/core/Component.ts:87

A handle on this component's World (ADR 0132): the same one Engine.findWorld returns. Load a scene into it, pause, connect or destroy it: this.world.loadScene("scenes/level2.scene.json"). Throws for a World no Engine owns.

Returns

WorldHandle

Inherited from

GameBehavior.world

Methods

awake()?

awake?(): void | Promise<void>;

Defined in: src/engine/core/Component.ts:156

Returns

void | Promise<void>

Inherited from

GameBehavior.awake


fixedUpdate()?

fixedUpdate?(): void;

Defined in: src/engine/core/Component.ts:159

Returns

void

Inherited from

GameBehavior.fixedUpdate


instantiate()

instantiate(prefabPath, options?): GameObject;

Defined in: src/engine/core/Component.ts:108

Instantiate a prefab in this component's World (ADR 0034), like GameObject.instantiate. Use it in code that may run after an await: by then the frame is over and the current World is the Engine's default one, which may not be this component's. A parent from another World throws.

Parameters

prefabPath

string

options?

InstantiateOptions = {}

Returns

GameObject

Inherited from

GameBehavior.instantiate


lateUpdate()?

lateUpdate?(): void;

Defined in: src/engine/core/Component.ts:161

Returns

void

Inherited from

GameBehavior.lateUpdate


onAudioMarker()?

onAudioMarker?(e): void;

Defined in: src/engine/core/Component.ts:202

A marker passing in the playlist an AudioSource on this node plays (ADR 0343): the Cue, Exit and Hit markers of its samples and its sequences' cue and exit markers, every type (e.type says which), delivered by the audio system (late update) on the first frame whose heard clock has passed it (e.time is exact). A playlist's beats and bars reach onMusicBeat/onMusicBar from there too. Defining the hook is the subscription; the handle's onMarker(type, fn) is the same for scripts that hold the handle.

Parameters

e

AudioMarkerEvent

Returns

void

Inherited from

GameBehavior.onAudioMarker


onCollisionEnter()?

onCollisionEnter?(collision): void;

Defined in: src/engine/core/Component.ts:173

A Collision2D in 2D physics, a Collision in 3D physics: annotate the parameter with the one your game uses.

Parameters

collision

PhysicsCollision

Returns

void

Inherited from

GameBehavior.onCollisionEnter


onCollisionExit()?

onCollisionExit?(collision): void;

Defined in: src/engine/core/Component.ts:176

Parameters

collision

PhysicsCollision

Returns

void

Inherited from

GameBehavior.onCollisionExit


onCollisionStay()?

onCollisionStay?(collision): void;

Defined in: src/engine/core/Component.ts:175

Every fixed step after onCollisionEnter while the two still touch (ADR 0093).

Parameters

collision

PhysicsCollision

Returns

void

Inherited from

GameBehavior.onCollisionStay


onControllerColliderHit()?

onControllerColliderHit?(hit): void;

Defined in: src/engine/core/Component.ts:180

A CharacterController or CharacterController2D on this node ran into a collider during move (ADR 0091): a ControllerColliderHit or ControllerColliderHit2D.

Parameters

hit

PhysicsControllerHit

Returns

void

Inherited from

GameBehavior.onControllerColliderHit


onDestroy()

onDestroy(): void;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:114

Returns

void

Overrides

GameBehavior.onDestroy


onDisable()

onDisable(): void;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:108

Returns

void

Overrides

GameBehavior.onDisable


onEnable()

onEnable(): void;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:85

Returns

void

Overrides

GameBehavior.onEnable


onJointBreak()?

onJointBreak?(
   joint, 
   force, 
   torque
): void;

Defined in: src/engine/core/Component.ts:178

A Joint or Joint2D on this node broke (its breakForce or breakTorque was exceeded); it is destroyed after this (ADR 0092).

Parameters

joint

Component

force

number

torque

number

Returns

void

Inherited from

GameBehavior.onJointBreak


onMusicBar()?

onMusicBar?(e): void;

Defined in: src/engine/core/Component.ts:189

The first beat of each bar of that music (e.beat is 1), delivered as onMusicBeat is.

Parameters

e

MusicEvent

Returns

void

Inherited from

GameBehavior.onMusicBar


onMusicBeat()?

onMusicBeat?(e): void;

Defined in: src/engine/core/Component.ts:187

A beat of the playlist an AudioSource on this node plays, when its playing entry has a tempo (a Sequence with a tempo, or a sample with one): delivered by the audio system (late update) on the first frame whose heard clock has passed it. After a gap of more than one beat the beats coalesce into one call with e.missed set (ADR 0166, 0343). Defining the hook is the subscription. e is reused: read it during the call, don't keep it.

Parameters

e

MusicEvent

Returns

void

Inherited from

GameBehavior.onMusicBeat


onMusicCue()?

onMusicCue?(e): void;

Defined in: src/engine/core/Component.ts:194

A cue of ADR 0166's music events. Playlists report cues as markers (onAudioMarker), so it isn't called for them (ADR 0343); kept so old scripts still compile.

Parameters

e

MusicEvent

Returns

void

Inherited from

GameBehavior.onMusicCue


onTriggerEnter()?

onTriggerEnter?(other): void;

Defined in: src/engine/core/Component.ts:168

The other collider: a Collider2D in 2D physics, a Collider in 3D physics (the physics plugins, ADR 0135). Annotate the parameter with the one your game uses: onTriggerEnter(other: Collider2D).

Parameters

other

Component

Returns

void

Inherited from

GameBehavior.onTriggerEnter


onTriggerExit()?

onTriggerExit?(other): void;

Defined in: src/engine/core/Component.ts:171

Parameters

other

Component

Returns

void

Inherited from

GameBehavior.onTriggerExit


onTriggerStay()?

onTriggerStay?(other): void;

Defined in: src/engine/core/Component.ts:170

Every fixed step after onTriggerEnter while the two still overlap (ADR 0093).

Parameters

other

Component

Returns

void

Inherited from

GameBehavior.onTriggerStay


start()?

start?(): void | Promise<void>;

Defined in: src/engine/core/Component.ts:158

Returns

void | Promise<void>

Inherited from

GameBehavior.start


update()

update(): void;

Defined in: src/plugins/subtitles/runtime/SubtitleDisplay.ts:120

Returns

void

Overrides

GameBehavior.update

Clone this wiki locally