SpriteSheet

Entitytracker.Modelceramic.SpriteSheet (Class)

Container for sprite animations and texture atlas data. Manages frame-based animations with timing information and texture regions.

Can be created from:

  • Aseprite JSON exports via SpriteAsset
  • Manual configuration using grid-based animations
  • Custom animation definitions

Example usage:

// Load from asset
var sheet = assets.sheet("character");

// Or create manually with grid
var sheet = new SpriteSheet();
sheet.texture = myTexture;
sheet.grid(32, 32);
sheet.addGridAnimation("walk", 0, 3, 0.1);

Instance Members

Array of animations available in this sprite sheet. Each animation contains frames with timing information.


sprite
atlas: TextureAtlas

The texture atlas containing all sprite frames. Automatically manages asset retention when changed.


sprite
gridWidth: Int

Grid cell width for grid-based sprite sheets. Set to -1 when not using grid layout.


sprite
gridHeight: Int

Grid cell height for grid-based sprite sheets. Set to -1 when not using grid layout.


sprite
texture: Texture

The texture used to display sprites in this spritesheet. Setting this creates an implicit atlas if one doesn't exist. This is a convenience property for simple single-texture sprite sheets.


sprite
source: String

The reference to the sprite sheet source file path. Used for debugging and asset tracking.


sprite
asset: SpriteAsset

The asset instance that loaded this sprite sheet. Null if the sheet was created manually.


sprite
invalidateAnimations(): Void

sprite
invalidateAtlas(): Void

sprite
invalidateGridWidth(): Void

sprite
invalidateGridHeight(): Void

sprite
grid(gridWidth: Int, gridHeight: Int): Void

Configure the sprite sheet as a grid with uniform cell dimensions. Required before using addGridAnimation().

Name Type Description
gridWidth Int Width of each cell in pixels
gridHeight Int Height of each cell in pixels

sprite
invalidateSource(): Void

sprite
destroy(): Void

sprite
animation(name: String): Null<SpriteSheetAnimation>

Find an animation by name.

Name Type Description
name String The animation name to search for
Returns Description
Null<SpriteSheetAnimation> The animation if found, null otherwise

sprite
addAnimation(animation: SpriteSheetAnimation): Void

Add a new animation to this sprite sheet.

Name Type Description
animation SpriteSheetAnimation The animation to add

sprite
addGridAnimation(name: String, start: Int, end: Int, frameDuration: Float): SpriteSheetAnimation

Add an animation using grid cell indices. Requires grid dimensions to be set first via grid(). Cells are numbered left-to-right, top-to-bottom starting from 0.

Name Type Description
name String Name of the animation to add
start Int Start cell index (inclusive)
end Int End cell index (inclusive)
frameDuration Float Duration of each frame in seconds
Returns Description
SpriteSheetAnimation The created animation instance

sprite
new(): Void

Private Members

sprite
unobservedAnimations: ReadOnlyArray<SpriteSheetAnimation>

sprite
unobservedAtlas: TextureAtlas

sprite
unobservedGridWidth: Int

sprite
unobservedGridHeight: Int

sprite
implicitAtlas: Bool

Internal: true if SpriteSheetAtlas instance was created implicitly from assigning a texture object.


sprite
unobservedSource: String

sprite
emitAnimationsChange(current: ReadOnlyArray<SpriteSheetAnimation>, previous: ReadOnlyArray<SpriteSheetAnimation>): Void

Event when animations field changes.

Name Type
current ReadOnlyArray<SpriteSheetAnimation>
previous ReadOnlyArray<SpriteSheetAnimation>

sprite
emitAtlasChange(current: TextureAtlas, previous: TextureAtlas): Void

Event when atlas field changes.

Name Type
current TextureAtlas
previous TextureAtlas

sprite
emitGridWidthChange(current: Int, previous: Int): Void

Event when gridWidth field changes.

Name Type
current Int
previous Int

sprite
emitGridHeightChange(current: Int, previous: Int): Void

Event when gridHeight field changes.

Name Type
current Int
previous Int

sprite
emitSourceChange(current: String, previous: String): Void

Event when source field changes.

Name Type
current String
previous String

sprite
cellsFromStartEnd(start: Int, end: Int): Array<Int>
Name Type
start Int
end Int
Returns
Array<Int>

sprite
replaceAtlas(newAtlas: TextureAtlas, prevAtlas: TextureAtlas): Void
Name Type
newAtlas TextureAtlas
prevAtlas TextureAtlas

sprite
replaceTexture(newTexture: Texture, prevTexture: Texture): Void
Name Type
newTexture Texture
prevTexture Texture

Metadata

Name Parameters
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()
:build tracker.macros.ObservableMacro.build()
:autoBuild tracker.macros.ObservableMacro.build()
:build tracker.macros.SerializableMacro.build()
:autoBuild tracker.macros.SerializableMacro.build()