arcade2d
Interface

AnimatedSpriteOptions

graphics/animated-sprite.types.ts:9

Construction-time configuration for an AnimatedSprite. Extends the shared TexturedGraphicsOptions (anchor, tint, alpha, visible) with the playback controls. Every field is optional; an omitted field takes the documented default.

Properties

readonly #
alpha?: number

Opacity in the range 0 (fully transparent) to 1 (fully opaque). Defaults to 1.

readonly #
anchor?: number | PointPrimitive

The anchor point — the spot on the graphic that sits on the host WorldObject's position — as a fraction of the graphic's size in each axis. 0 is the left/top edge, 1 the right/bottom, 0.5 the centre. Pass a single number to use it for both axes, or a PointPrimitive for independent values.

Defaults to 0.5 (centred), which differs from the renderer's own top-left default. Centring matches arcade2d's convention that a WorldObject's position is its visual origin.

readonly #
autoplay?: boolean

Whether the animation starts playing immediately on construction. When false, the sprite shows its first frame and waits for AnimatedSprite.play. Defaults to true.

readonly #
fps?: number

Playback rate in frames per second. The per-frame duration is 1000 / fps milliseconds. Defaults to 12. Must be a positive, finite number — a zero, negative, or non-finite rate throws ErrorCode.ANIMATED_SPRITE_INVALID_FPS.

readonly #
layer?: Layer

The render layer this graphic draws in, as a Layer token from the world's LayerSet (e.g. layers.get('characters')).

Layers are opt-in per world. If the world was created with layers, this is required — omitting it throws ErrorCode.LAYER_UNSPECIFIED, since a layered world has no implicit default band. If the world has no layer set, this must be omitted — passing it throws ErrorCode.LAYER_SET_ABSENT. Change it later with AbstractGraphics.layer to move the graphic between bands.

readonly #
loop?: boolean

Whether playback wraps from the last frame back to the first. When false, the animation holds on the final frame and stops (firing AnimatedSpriteOptions.onComplete). Defaults to true.

readonly #
onComplete?: () => void

Invoked once when a non-looping animation reaches and holds its final frame. Never fires while AnimatedSpriteOptions.loop is true.

readonly #
tint?: number

Multiplicative tint as a 24-bit RGB integer (e.g. 0xff0000 for red). 0xffffff (white) leaves colours unchanged. For Text this multiplies on top of the glyph TextOptions.fill. Defaults to 0xffffff.

readonly #
visible?: boolean

Whether the graphic is drawn at all. A hidden graphic still ticks and keeps its transform in sync; it is simply skipped by the renderer. Defaults to true.

ESC