Sprite
Sprite visual that displays animations from sprite sheets. Supports frame-by-frame animation playback with timing control, easing, and automatic size computation from frames.
The sprite can play animations from SpriteSheet data which can be loaded from various formats including Aseprite JSON exports.
Example usage:
var sprite = new Sprite();
sprite.sheet = assets.sheet("character");
sprite.animation = "walk";
sprite.loop = true;
Instance Members
Whether to automatically compute the sprite's size from the current animation frame. When true, the sprite will resize itself to match the original frame dimensions.
The current texture region being displayed. This is automatically updated during animation playback.
The name of the current animation as a string.
This is the string representation of the animation
property.
Optional easing function to apply to animation playback. When set, the animation timeline will be transformed by this easing.
Time scale multiplier for animation playback speed. Values > 1.0 speed up the animation, < 1.0 slow it down.
The current animation being played. Can be a String or an enum value depending on the type parameter T. Setting this property resets the animation time to 0.
Horizontal offset applied to the frame position. Useful for fine-tuning sprite alignment.
Vertical offset applied to the frame position. Useful for fine-tuning sprite alignment.
The sprite sheet containing animation data. Setting this property resets the animation time.
Set to false
if you want to disable auto update on this sprite object.
If auto update is disabled, you become responsible to explicitly call
update(delta)
at every frame yourself. Use this if you want to have control over
when the animation update is actually happening. Don't use it to pause animation.
(animation can be paused with paused
property instead)
Is this sprite paused? When true, animation playback is suspended but time is preserved.
Is this sprite looping? When true, animation restarts from beginning after completion. When false, animation stops on the last frame.
The internal quad used to render the sprite frame. This is automatically managed by the sprite.
Current playback time in seconds within the animation. Automatically increments during update unless paused.
The current animation data from the sprite sheet. Automatically resolved from animationName when accessed.
Set both frame offset values at once.
Name | Type | Description |
---|---|---|
frameOffsetX |
Float | Horizontal offset |
frameOffsetY |
Float | Vertical offset |
Compute the sprite size based on the first frame of the current animation. This is called automatically when autoComputeSize is true and an animation is set.
Update the sprite animation. This is called automatically each frame if autoUpdate is true.
Name | Type | Description |
---|---|---|
delta |
Float | Time elapsed since last update in seconds |
Compute the visual content of the sprite. Updates the internal quad position and texture based on the current frame. This is called automatically when contentDirty is true.
Destroy this sprite and remove it from the update system.
Create a new Sprite instance. The sprite is automatically added to the SpriteSystem for updates.
Private Members
Internal flag tracking when animation data needs to be refreshed.
The current frame being displayed from the animation.
Metadata
Name | Parameters |
---|---|
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |