GraphicsAPI reference
Class SpriteAtlas
Namespace: MicroEngine.Graphics
Assembly: MicroEngine.Graphics2D.dll
Guide: Graphics
Named sprites packed into one texture, built by Build. The atlas owns the texture:
dispose the atlas (usually in Game.Unload) when its sprites are no longer drawn.
public sealed class SpriteAtlas : IDisposableInheritance
Implements
Fields
DefaultFrameDuration
The duration of tagged frames whose file gives none, in seconds (a tenth of a second).
public const float DefaultFrameDuration = 0.1Field Value
Properties
Animations
Names of the animations the atlas file tagged (Aseprite frame tags).
public IReadOnlyCollection<string> Animations { get; }Property Value
Names
Names of every sprite in the atlas.
public IReadOnlyCollection<string> Names { get; }Property Value
Texture
The packed texture shared by every sprite of the atlas.
public Texture Texture { get; }Property Value
this[string]
The sprite named name.
public Sprite this[string name] { get; }Property Value
Exceptions
No sprite has that name; check with Contains.
Methods
Clip(string, bool)
The clip of the frame tag name, with each frame’s duration from the file and its direction
(forward, reverse, ping-pong) applied. Built once per tag and loop setting, then shared.
public AnimationClip Clip(string name, bool loop = true)Parameters
name string
loop bool
Returns
Exceptions
The atlas has no tag of that name.
Clip(string, float, bool)
A clip of the numbered frames “name0”, “name1”… (or “name1”, “name2”… when the numbering starts at 1, as many
packs do) at framesPerSecond.
public AnimationClip Clip(string name, float framesPerSecond, bool loop = true)Parameters
name string
framesPerSecond float
loop bool
Returns
Exceptions
No frames have that name.
Contains(string)
Whether a sprite named name exists.
public bool Contains(string name)Parameters
name string
Returns
Create(Texture, AtlasData, bool)
Makes an atlas from texture and the frames a packing tool described in data.
public static SpriteAtlas Create(Texture texture, AtlasData data, bool ownsTexture = true)Parameters
texture Texture
The atlas image as a texture.
data AtlasData
The frames and tags (Parse).
ownsTexture bool
Whether disposing the atlas disposes the texture (true by default).
Returns
Exceptions
A frame lies outside the texture, or two frames share a name.
Dispose()
Disposes the texture (unless the atlas was created with ownsTexture: false); sprites of this atlas must not be drawn afterwards.
public void Dispose()Frames(string)
The “name0”..“nameN” frames added through AddFrames, in order; a numbering that starts at 1 (“walk1”, “walk2”… as in many packs) works too. Collected once per name and shared, read-only: it can be called every frame.
public IReadOnlyList<Sprite> Frames(string name)Parameters
name string
Returns
Exceptions
No sprite is named name followed by 0 or 1.
Load(IGraphicsDevice, string, AtlasOptions?, TextureFilter?, string?)
Loads an atlas made by a packing tool: its JSON or XML file and the image it names (next to the file), or
imagePath. The atlas owns the texture.
public static SpriteAtlas Load(IGraphicsDevice device, string path, AtlasOptions? options = null, TextureFilter? filter = null, string? imagePath = null)Parameters
device IGraphicsDevice
Creates the texture.
path string
The atlas file (TexturePacker or Aseprite JSON, Starling XML).
options AtlasOptions?
Default pivot and naming; null for Default.
filter TextureFilter?
The texture’s filter; null for the device’s default.
imagePath string?
The image, when the file names none or names it wrongly; null to use the file’s.
Returns
Exceptions
The atlas file or its image does not exist.
The file is not an atlas, or does not fit its image; the message names the file.