SpriteAsset

EntityAssetceramic.SpriteAsset (Class)

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

sprite
sheet: SpriteSheet

The loaded sprite sheet containing animations. Available after successful loading.


sprite
text: String

Raw text content of the sprite data file. Contains the JSON or other format data before parsing.


sprite
atlas: TextureAtlas

The texture atlas associated with this sprite. Retrieved from the internal atlas asset.


sprite
invalidateSheet(): Void

sprite
invalidateText(): Void

sprite
load(): Void

Load the sprite asset. Automatically detects format based on file extension and loads appropriately.


sprite
destroy(): Void

Clean up and destroy the sprite asset. Destroys associated sheet and Aseprite data if present.


sprite
new(name: String, ?variant: String, ?options: Null<AssetOptions>): Void
Name Type Default
name String
variant String (optional)
options Null<AssetOptions> (optional)

Private Members

sprite
unobservedSheet: SpriteSheet

sprite
unobservedText: String

sprite
atlasAsset: AtlasAsset

sprite
asepriteData: AsepriteData

sprite
emitSheetChange(current: SpriteSheet, previous: SpriteSheet): Void

Event when sheet field changes.

Name Type
current SpriteSheet
previous SpriteSheet

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

Event when text field changes.

Name Type
current String
previous String

sprite
asepritePostPack(): Void

sprite
loadSpriteSheet(): Void

Load a standard sprite sheet file (.sprite or other custom formats). Uses SpriteSheetParser to parse the data after loading the atlas.


sprite
loadAse(): Void

Load a native Aseprite file (.ase or .aseprite). Extracts frames and animations directly from the binary format. Requires the ase plugin to be enabled.


sprite
parseAtlas(text: String): TextureAtlas

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

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