SpriteSheet
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.
The texture atlas containing all sprite frames. Automatically manages asset retention when changed.
Grid cell width for grid-based sprite sheets. Set to -1 when not using grid layout.
Grid cell height for grid-based sprite sheets. Set to -1 when not using grid layout.
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.
The reference to the sprite sheet source file path. Used for debugging and asset tracking.
The asset instance that loaded this sprite sheet. Null if the sheet was created manually.
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 |
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 |
Add a new animation to this sprite sheet.
Name | Type | Description |
---|---|---|
animation |
SpriteSheetAnimation | The animation to add |
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 |
Private Members
Internal: true
if SpriteSheetAtlas instance was created
implicitly from assigning a texture object.
emitAnimationsChange(current: ReadOnlyArray<SpriteSheetAnimation>, previous: ReadOnlyArray<SpriteSheetAnimation>): Void
Event when animations field changes.
Name | Type |
---|---|
current |
ReadOnlyArray<SpriteSheetAnimation> |
previous |
ReadOnlyArray<SpriteSheetAnimation> |
Event when atlas field changes.
Name | Type |
---|---|
current |
TextureAtlas |
previous |
TextureAtlas |
Event when gridWidth field changes.
Name | Type |
---|---|
current |
Int |
previous |
Int |
Event when gridHeight field changes.
Name | Type |
---|---|
current |
Int |
previous |
Int |
Event when source field changes.
Name | Type |
---|---|
current |
String |
previous |
String |
Name | Type |
---|---|
start |
Int |
end |
Int |
Returns |
---|
Array<Int> |
Name | Type |
---|---|
newAtlas |
TextureAtlas |
prevAtlas |
TextureAtlas |
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() |