Skip to content

AnimationProps

How an animated sprite plays (engine.animation(frames, props)): a sprite’s props and these.

engine.animation('hero/run', { fps: 12, x: 200, y: 500, anchor: 0.5 })

optional x?: number

Position in the parent, stage units (y downwards).

SpriteProps.x


optional y?: number

Position in the parent, stage units (y downwards).

SpriteProps.y


optional rotation?: number

Radians, clockwise.

SpriteProps.rotation


optional scale?: number

Both scales at once.

SpriteProps.scale


optional scaleX?: number

Horizontal scale (negative: mirrored).

SpriteProps.scaleX


optional scaleY?: number

Vertical scale.

SpriteProps.scaleY


optional alpha?: number

0–1, multiplied down the tree.

SpriteProps.alpha


optional visible?: boolean

Hidden nodes and their children are not drawn.

SpriteProps.visible


optional tint?: ColorLike

A colour multiplied with the pixels (white: none), as 0xRRGGBB or CSS.

SpriteProps.tint


optional blend?: Blend

‘add’ for glows and sparks.

SpriteProps.blend


optional z?: number

Drawing order among siblings: higher on top (equal: order of adding).

SpriteProps.z


optional anchor?: number | { x: number; y: number; }

Anchor, 0–1 of the size: 0 top-left, 0.5 the middle. A number sets both.

SpriteProps.anchor


optional width?: number

Local width, stage units (sprites and shapes: stretched to it).

SpriteProps.width


optional height?: number

Local height, stage units.

SpriteProps.height


optional hitRadius?: number

Hit tests use a circle of this radius (local units) around the origin instead of the rectangle.

SpriteProps.hitRadius


optional clip?: ClipRect | null

Clips the node and its children to this rectangle, in the node’s own units (null: no clip).

SpriteProps.clip


optional mask?: Node | null

Shows the node and its children only where this node is opaque (null: no mask). See Node.mask.

SpriteProps.mask


optional filters?: Filter[] | null

Filters, in order (null: none). See Node.filters.

SpriteProps.filters


optional frame?: string | Frame

An atlas frame, or the name of a loaded or baked one.

SpriteProps.frame


optional slice?: number | Insets

Nine-slice insets in frame pixels: one number for all sides, or [top, right, bottom, left]. The corners keep their size when the sprite is resized, the edges and the middle stretch. Default: the frame’s own (an atlas’s scale9Borders), else none.

SpriteProps.slice


optional fps?: number

Frames per second (default 12); ignored for frames with their own durations, unless set.


optional loop?: boolean

Start again after the last frame (default true); false: stop on it and call onComplete.


optional playing?: boolean

Starts playing at once (default true).


optional speed?: number

Time scale: 2 plays twice as fast, -1 backwards. Default 1.


optional onComplete?: () => void

Called when a non-looping animation reaches its last frame.

void