SpriteAsset
Asset loader for sprite sheets and animations. Supports multiple formats:
- Aseprite JSON format (.sprite files)
- Native Aseprite files (.ase, .aseprite) when ase plugin is enabled
- Custom sprite sheet formats via SpriteSheetParser
Automatically handles:
- Texture atlas loading and management
- Hot-reload support for development
- Animation parsing from frame tags
- Memory management and reference counting
Example usage:
assets.add(Sprites.CHARACTER);
assets.onceComplete(this, success -> {
var sprite = new Sprite();
sprite.sheet = assets.sheet(Sprites.CHARACTER);
sprite.animation = "idle";
});
Instance Members
The loaded sprite sheet containing animations. Available after successful loading.
Raw text content of the sprite data file. Contains the JSON or other format data before parsing.
The texture atlas associated with this sprite. Retrieved from the internal atlas asset.
Load the sprite asset. Automatically detects format based on file extension and loads appropriately.
Clean up and destroy the sprite asset. Destroys associated sheet and Aseprite data if present.
Name | Type | Default |
---|---|---|
name |
String | |
variant |
String | (optional) |
options |
Null<AssetOptions> | (optional) |
Private Members
Event when sheet field changes.
Name | Type |
---|---|
current |
SpriteSheet |
previous |
SpriteSheet |
Event when text field changes.
Name | Type |
---|---|
current |
String |
previous |
String |
Load a standard sprite sheet file (.sprite or other custom formats). Uses SpriteSheetParser to parse the data after loading the atlas.
Load a native Aseprite file (.ase or .aseprite). Extracts frames and animations directly from the binary format. Requires the ase plugin to be enabled.
Custom atlas parsing method provided to AtlasAsset. Delegates to SpriteSheetParser for sprite-specific atlas formats.
Name | Type | Description |
---|---|---|
text |
String | The raw atlas text data |
Returns | Description |
---|---|
TextureAtlas | Parsed texture atlas |
assetFilesDidChange(newFiles: ReadOnlyMap<String, Float>, previousFiles: ReadOnlyMap<String, Float>): Void
Handle file change notifications for hot-reload. Automatically reloads the sprite when the source file changes.
Name | Type | Description |
---|---|---|
newFiles |
ReadOnlyMap<String, Float> | Map of current file paths to modification times |
previousFiles |
ReadOnlyMap<String, Float> | Map of previous file paths to modification times |
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() |