Sprite

EntityVisualceramic.Sprite (Class)

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

sprite
autoComputeSize: Bool

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.


sprite
region: TextureAtlasRegion

The current texture region being displayed. This is automatically updated during animation playback.


sprite
animationName: String

The name of the current animation as a string. This is the string representation of the animation property.


sprite
easing: Anonymous

Optional easing function to apply to animation playback. When set, the animation timeline will be transformed by this easing.


sprite
timeScale: Float

Time scale multiplier for animation playback speed. Values > 1.0 speed up the animation, < 1.0 slow it down.


sprite
animation: ceramic.Sprite.T

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.


sprite
frameOffsetX: Float

Horizontal offset applied to the frame position. Useful for fine-tuning sprite alignment.


sprite
frameOffsetY: Float

Vertical offset applied to the frame position. Useful for fine-tuning sprite alignment.


sprite
sheet: SpriteSheet

The sprite sheet containing animation data. Setting this property resets the animation time.


sprite
autoUpdate: Bool

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)


sprite
paused: Bool

Is this sprite paused? When true, animation playback is suspended but time is preserved.


sprite
loop: Bool

Is this sprite looping? When true, animation restarts from beginning after completion. When false, animation stops on the last frame.


sprite
quad: Quad

The internal quad used to render the sprite frame. This is automatically managed by the sprite.


sprite
time: Float

Current playback time in seconds within the animation. Automatically increments during update unless paused.


sprite
currentAnimation: SpriteSheetAnimation

The current animation data from the sprite sheet. Automatically resolved from animationName when accessed.


sprite
frameOffset(frameOffsetX: Float, frameOffsetY: Float): Void

Set both frame offset values at once.

Name Type Description
frameOffsetX Float Horizontal offset
frameOffsetY Float Vertical offset

sprite
computeSizeFromAnimation(): Void

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.


sprite
update(delta: Float): Void

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

sprite
computeContent(): Void

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.


sprite
destroy(): Void

Destroy this sprite and remove it from the update system.


sprite
new(): Void

Create a new Sprite instance. The sprite is automatically added to the SpriteSystem for updates.

Private Members

sprite
currentAnimationDirty: Bool

Internal flag tracking when animation data needs to be refreshed.


sprite
currentAnimationFrame: SpriteSheetFrame

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()