Skip to main content

Overview

These components render images, sprite sheet animations, and text onto the PixiJS stage. All sprite and text components accept standard PixiJS positioning props (x, y, scale, rotation, etc.) inherited from their underlying PIXI display objects.

<Sprite>

Renders a single static texture loaded from the asset manifest. The texture is looked up by key from stateApp.loadedAssets.

Props

string
required
The key used in the asset manifest (createApp({ assets })) to identify this texture. Must correspond to an asset with type: 'sprite'.
boolean
When true, logs an error to the console if the texture key is not found in loadedAssets. Useful during development.
PIXI.Texture
Not normally set directly on <Sprite> — the texture is resolved automatically from key. Use BaseSprite if you need to supply a texture directly.
number
Horizontal position in pixels from the parent origin. Default 0.
number
Vertical position in pixels from the parent origin. Default 0.
number | PointData
Sets the sprite’s origin/pivot. 0 = top-left, 0.5 = centre, 1 = bottom-right. Accepts a uniform number or { x, y }. Default 0.
number | PointData
Uniform or per-axis scale. Default 1.
number
Rotation in radians. Default 0.
number
Opacity from 0 to 1. Default 1.
boolean
Whether the sprite is rendered. Default true.
number
Sort order within the parent container. Default 0.
PIXI.ColorSource
Colour tint applied to the texture. Default 0xffffff (no tint).
boolean
Apply this sprite as an alpha mask on the parent container.
Cursor
CSS cursor string shown on hover.

Example


<AnimatedSprite>

Renders a frame-by-frame animation from an array of textures. Wraps PIXI.AnimatedSprite.

Props

PIXI.Texture[] | PIXI.FrameObject[]
required
Array of textures (or frame objects with texture and time) that form the animation frames.
boolean
When true, calls gotoAndPlay(0). When false, calls gotoAndStop(0). Use this to start and stop the animation declaratively. Default false.
number
Playback speed multiplier. 1 = normal speed, 0.5 = half speed. Default 1.
boolean
Whether the animation loops. Default true.
number
Horizontal position. Default 0.
number
Vertical position. Default 0.
number | PointData
Origin/pivot point. Default 0 (top-left).
number | PointData
Uniform or per-axis scale. Default 1.
number
Opacity from 0 to 1. Default 1.
boolean
Whether the sprite is rendered. Default true.
number
Sort order within the parent. Default 0.
PIXI.ColorSource
Colour tint applied to all frames. Default 0xffffff.
Cursor
CSS cursor string.

Example


<SpriteSheet>

A specialised <AnimatedSprite> that resolves its textures automatically from the asset manifest. Use with assets declared as type: 'spriteSheet'.

Props

string
required
Asset manifest key for a spriteSheet asset. The loaded texture array is passed automatically to the underlying <AnimatedSprite>.
boolean
Whether to play the animation. Default false.
number
Playback speed multiplier. Default 1.
boolean
Whether the animation loops. Default true.
number
Horizontal position. Default 0.
number
Vertical position. Default 0.
number | PointData
Origin/pivot point. Default 0.
number
Opacity from 0 to 1. Default 1.
boolean
Whether the sprite is rendered. Default true.
number
Sort order within the parent. Default 0.
Cursor
CSS cursor string.

Example


<Text>

Renders a text string using a PixiJS canvas-rendered font. Wraps PIXI.Text.

Props

string
The string to display.
PIXI.TextStyle | Partial<PIXI.TextStyleOptions>
Text styling options: font family, size, weight, colour, stroke, word wrap, alignment, etc. See the PixiJS TextStyle docs for all options.
(size: { width: number; height: number }) => void
Callback fired whenever the rendered size of the text changes — on mount and whenever text or style changes. Useful for dynamically repositioning elements relative to text bounds.
number
Horizontal position. Default 0.
number
Vertical position. Default 0.
number | PointData
Origin/pivot point. 0.5 centres the text on x/y. Default 0.
number | PointData
Uniform or per-axis scale. Default 1.
number
Opacity from 0 to 1. Default 1.
boolean
Whether the text is rendered. Default true.
number
Sort order within the parent. Default 0.
Cursor
CSS cursor string.

Example


<BitmapText>

Renders text using a pre-rasterised bitmap font. Faster than <Text> for frequently updated strings (scores, counters) because it does not re-rasterise on every change. Requires a font asset loaded via the manifest. <BitmapText> has the same props as <Text>. The style.fontFamily must match the name of a loaded bitmap font.

Props

string
The string to display.
PIXI.TextStyle | Partial<PIXI.TextStyleOptions>
Text style. fontFamily must match the loaded bitmap font name.
(size: { width: number; height: number }) => void
Callback fired on mount and whenever text or style changes with the current rendered dimensions.
number
Horizontal position. Default 0.
number
Vertical position. Default 0.
number | PointData
Origin/pivot point. Default 0.
number
Opacity. Default 1.
boolean
Whether the text is rendered. Default true.
number
Sort order within the parent. Default 0.
Cursor
CSS cursor string.

Example

Use <BitmapText> over <Text> for values that update every frame (live counters, timers). Bitmap fonts are rendered once and reused, so repeated text updates are cheaper.