Optionaloptions: Texture<TextureSource<any>> | SpriteOptionsfires once when a non-looping animation reaches its last frame
the packed additive colour; use setColorAdd or lerpTint rather than setting it raw
how long the current animation has been running, startTime and all
Where the current frame is drawn relative to the sprite's own position, in pixels. The caller
adds it, as in sprite.position.set(x + sprite.frameOffset.x, y + sprite.frameOffset.y). Both
are zero for a frame with no offset of its own.
Optionaloptions: AnimationOptionsMoves the sprite strength of the way towards color, leaving its shading intact.
This sets both halves of the transform: the tint carries 1 - strength and the
additive term carries color × strength.
Starts an animation.
Playing the one already running does nothing, so a movement loop can call
play('walk') every frame without restarting it. Pass restart to force it.
back to the texture's own colours
each 0 to 1
extra alpha to add, usually 0
a solid silhouette in color, keeping only the sprite's shape
A sprite that plays named animations, and can still be tinted.
Animations are registered once and played by name, which is how a character ends up reading as
hero.play('walk')rather than juggling frame arrays.Nothing advances on its own: call
update(dt)from the scene, or add the sprite to aSpriteGroup, so that pausing the game pauses the animations with it.Frames may carry their own duration, and the animation may start partway into itself, which is what Wesnoth's
image=a.png:120,b.png:80andstart_time=-450mean. A frame may also carry an offset, so a swing recoils a few pixels without a second texture:frameOffsetreports it, and the caller adds it where it already positions the sprite. The framework does not apply it itself, on purpose - this sprite's position belongs to whoever put it there (aGridMover, a walk tween, a camera projection), and a sprite that overwroteyevery frame would undo that every frame.FloatingTextlearned the same rule the hard way.Reduced motion deliberately does not pause this. A frame cycle is usually game state - a walking enemy that freezes when the player has asked for less motion is a bug, not an accommodation, and the article's own "Don't Reduce Too Much" is about exactly this. A game whose loops are purely decorative (torches, rippling water) can stop those itself through
paused, or not add the sprite at all.Extends
TintedSpritedirectly, soalphacomposes withtint/colorAddthe same way here too - a translucent, animated ghost isalpha = 0.5plus whatever tint, no different from a still one (seeTintedSprite's own doc comment).Example