Skip to content

SplitTextComponent

Defined in: packages/renderer/src/SplitTextComponent.ts:109

Displays text split into per-character / per-word / per-line display objects, for animated and rich text — typewriter reveals, per-letter colour / wave, staggered line entrances. Wraps Pixi v8’s SplitText (canvas) / SplitBitmapText (bitmap); the segments are exposed as SplitTextComponent.chars, SplitTextComponent.words, and SplitTextComponent.lines for the game to animate directly.

For static or simple dynamic strings prefer TextComponent — a single display object is cheaper and SplitText re-layout on every text change is not free.

Pixi marks SplitText experimental; its char spacing can differ slightly from Text (browser kerning is lost once glyphs are split).

  • Component

new SplitTextComponent(options): SplitTextComponent

Defined in: packages/renderer/src/SplitTextComponent.ts:124

SplitTextComponentOptions

SplitTextComponent

Component.constructor

enabled: boolean

Defined in: packages/core/dist/index.d.ts:1872

Whether this component is active. Disabled components are skipped by ComponentUpdateSystem.

Component.enabled


entity: Entity

Defined in: packages/core/dist/index.d.ts:1870

Back-reference to the owning entity. Set by the engine when the component is added to an entity. Do not set manually.

Component.entity


readonly isBitmap: boolean

Defined in: packages/renderer/src/SplitTextComponent.ts:113

Whether this renders with a bitmap font (SplitBitmapText).


readonly layerName: string

Defined in: packages/renderer/src/SplitTextComponent.ts:114


readonly splitText: SplitText | SplitBitmapText

Defined in: packages/renderer/src/SplitTextComponent.ts:111

The underlying Pixi SplitText / SplitBitmapText container.

get alpha(): number

Defined in: packages/renderer/src/SplitTextComponent.ts:253

number

set alpha(alpha): void

Defined in: packages/renderer/src/SplitTextComponent.ts:250

Opacity (0-1).

number

void


get charAnchor(): SegmentAnchor

Defined in: packages/renderer/src/SplitTextComponent.ts:219

SegmentAnchor

set charAnchor(anchor): void

Defined in: packages/renderer/src/SplitTextComponent.ts:215

Transform origin for each character (normalized 0–1).

SegmentAnchor

void


get chars(): (Text | BitmapText)[]

Defined in: packages/renderer/src/SplitTextComponent.ts:175

Individual character segments (Text or BitmapText), in reading order.

(Text | BitmapText)[]


get context(): EngineContext

Defined in: packages/core/dist/index.d.ts:1885

Access the EngineContext from the entity’s scene. Throws if the entity is not in a scene.

EngineContext

Component.context


get lineAnchor(): SegmentAnchor

Defined in: packages/renderer/src/SplitTextComponent.ts:237

SegmentAnchor

set lineAnchor(anchor): void

Defined in: packages/renderer/src/SplitTextComponent.ts:233

Transform origin for each line (normalized 0–1).

SegmentAnchor

void


get lines(): Container<ContainerChild>[]

Defined in: packages/renderer/src/SplitTextComponent.ts:185

Line-group containers, each holding its word containers.

Container<ContainerChild>[]


get renderObject(): Container

Defined in: packages/renderer/src/SplitTextComponent.ts:322

The underlying Pixi display object.

Container


get scene(): Scene

Defined in: packages/core/dist/index.d.ts:1880

Access the entity’s scene. Throws if the entity is not in a scene. Prefer this over threading through this.entity.scene in component code.

Scene

Component.scene


get tint(): number

Defined in: packages/renderer/src/SplitTextComponent.ts:245

number

set tint(color): void

Defined in: packages/renderer/src/SplitTextComponent.ts:242

Tint color applied to the whole text (cascades to every segment).

number

void


get wordAnchor(): SegmentAnchor

Defined in: packages/renderer/src/SplitTextComponent.ts:228

SegmentAnchor

set wordAnchor(anchor): void

Defined in: packages/renderer/src/SplitTextComponent.ts:224

Transform origin for each word (normalized 0–1).

SegmentAnchor

void


get words(): Container<ContainerChild>[]

Defined in: packages/renderer/src/SplitTextComponent.ts:180

Word-group containers, each holding its character segments.

Container<ContainerChild>[]

_runCleanups(): void

Defined in: packages/core/dist/index.d.ts:1926

Internal

Run and clear all registered cleanups. Called by Entity.remove() and Entity._performDestroy() before onRemove/onDestroy.

void

Component._runCleanups


protected addCleanup(fn): void

Defined in: packages/core/dist/index.d.ts:1920

Register a cleanup function to run when this component is removed or destroyed.

() => void

void

Component.addCleanup


optional afterRestore(data, resolve): void

Defined in: packages/core/dist/index.d.ts:1940

Called after onAdd() during save/load restoration. Apply state that depends on onAdd() having run.

unknown

SnapshotResolver

void

Component.afterRestore


optional fixedUpdate(dt): void

Defined in: packages/core/dist/index.d.ts:1936

Called every fixed timestep by the built-in ComponentUpdateSystem.

number

void

Component.fixedUpdate


inspectRender(): SplitTextRenderFacet

Defined in: packages/renderer/src/SplitTextComponent.ts:310

Derived render facet for the Inspector. Beyond the shared world-space bounds and container-level visible, this walks the per-character segments and reports glyphs (one { visible } per char in reading order) plus visibleText — the substring currently painted. This is the read-only window into a typewriter reveal: where serialize() reports the full declared string, visibleText reports only the glyphs whose chars[i].visible is still on. Not part of serialize(); see computeRenderFacet for the bounds coordinate space.

Note: Pixi’s chars array (and therefore glyphs / visibleText) contains only the rendered glyph segments — whitespace is laid out via words/lines and is NOT a char. So visibleText strips spaces: a fully revealed "Hello world" reports "Helloworld". Use it to compare which glyphs are on screen, not to reconstruct the original string verbatim.

SplitTextRenderFacet


protected listen<T>(entity, token, handler): void

Defined in: packages/core/dist/index.d.ts:1912

Subscribe to events on any entity, auto-unsubscribe on removal.

T

Entity

EventToken<T>

(data) => void

void

Component.listen


protected listenScene<T>(token, handler): void

Defined in: packages/core/dist/index.d.ts:1918

Subscribe to scene-level events, auto-unsubscribe on removal. Handlers fire for bubbled entity events (entity = source) and scene.emit events (entity = undefined).

T

EventToken<T>

(data, entity?) => void

void

Component.listenScene


onAdd(): void

Defined in: packages/renderer/src/SplitTextComponent.ts:326

Called when the component is added to an entity.

void

Component.onAdd


onDestroy(): void

Defined in: packages/renderer/src/SplitTextComponent.ts:333

Called when the component is destroyed (entity destroyed or component removed).

void

Component.onDestroy


optional onRemove(): void

Defined in: packages/core/dist/index.d.ts:1930

Called when the component is removed from an entity.

void

Component.onRemove


resplit(): void

Defined in: packages/renderer/src/SplitTextComponent.ts:210

Re-split now. Only needed when constructed with autoSplit: false — after mutating text / style, call this to apply the change in one pass.

void


serialize(): SplitTextData

Defined in: packages/renderer/src/SplitTextComponent.ts:257

Return a JSON-serializable snapshot of this component’s state. Used by the save system.

SplitTextData

Component.serialize


protected service<T>(key): T

Defined in: packages/core/dist/index.d.ts:1902

Lazy proxy-based service resolution. Can be used at field-declaration time:

readonly input = this.service(InputManagerKey);

The actual resolution is deferred until first property access.

T extends object

ServiceKey<T>

T

Component.service


setStyle(style): void

Defined in: packages/renderer/src/SplitTextComponent.ts:195

Replace the text style (re-splits when autoSplit is on).

TextStyleOptions

void


setText(value): void

Defined in: packages/renderer/src/SplitTextComponent.ts:190

Replace the displayed string (re-splits when autoSplit is on).

string

void


protected sibling<C>(cls): C

Defined in: packages/core/dist/index.d.ts:1910

Lazy proxy-based sibling component resolution. Can be used at field-declaration time:

readonly anim = this.sibling(AnimatedSpriteComponent);

The actual resolution is deferred until first property access.

C extends Component

ComponentClass<C>

C

Component.sibling


optional update(dt): void

Defined in: packages/core/dist/index.d.ts:1934

Called every frame by the built-in ComponentUpdateSystem.

number

void

Component.update


protected use<T>(key): T

Defined in: packages/core/dist/index.d.ts:1893

Resolve a service by key, cached after first lookup. Scene-scoped values (registered via scene._registerScoped) take precedence over engine scope. A key declared with scope: "scene" that falls back to engine scope emits a one-shot dev warning — almost always signals a missed beforeEnter hook.

T

ServiceKey<T>

T

Component.use


static fromSnapshot(data): SplitTextComponent

Defined in: packages/renderer/src/SplitTextComponent.ts:277

SplitTextData

SplitTextComponent