Detailed Description

SPA (SPrite Animation) is a custom file format which holds optimized sprite animations and also supports alpha. As it's a custom format, we also have a freely available tool on the website which will encode a series of images into an .SPA file. Important Note: You must add .bytes onto the end of any .spa file in your Resources folder, otherwise it won't work! (e.g. countdown.spa.bytes).

Public Member Functions

 SPA (int frameWidth, int frameHeight, int frameRate)
 Creates a new empty SPA animation. More...
 
 SPA (string name, int frameWidth, int frameHeight, int frameRate)
 Creates a new empty SPA animation. More...
 
void ChangeFrameRate (int newRate)
 Changes the framerate of this animation. More...
 
void CreateSprites (int spriteCount, uint frameCount)
 Creates space for the given number of sprites which hold the given total number of frames. More...
 
 SPA (string name, byte[] binaryData)
 Creates a new SPA animation with the given name from the given binary data. More...
 
SPACharacter GetCharacter (int charcode)
 Gets a character from this SPA, if it exists. More...
 
SPAMapEntry GetFromMap (int index)
 Gets the entry from the map. Index is most often e.g. charcode. More...
 
void AddToMap (int index, SPAMapEntry entry)
 Adds the given map entry to the map. More...
 
SPAInstance GetInstance ()
 Creates a playable instance of this animation. Instances are required as the same animation could be visible multiple times. More...
 
SPASprite GetSprite (int id)
 Gets a sprite with the given ID. More...
 

Static Public Member Functions

static void Clear ()
 Clears all active SPA animations. More...
 
static SPA Get (string name)
 Gets an already loaded SPA from the cache. More...
 
static int ActiveCount ()
 Gets how many animations are actively playing. More...
 
static void Update (float deltaTime)
 Advances playback of any running animations and performs some garbage collection. Called by UI.Update. More...
 
static implicit operator SpaFormat (SPA spa)
 Implicitly converts an SPA into an SPAFormat object. Used when adding an SPA to the image cache. More...
 

Public Attributes

Gif.Gif ParentGif
 The GIF object that this SPA is for. More...
 
int FrameRate
 The frame rate in frames/second. More...
 
int FrameWidth
 The width of a frame. More...
 
int FrameHeight
 The height of a frame. More...
 
uint FrameCount
 The number of frames in this animation. More...
 
SPASprite[] Sprites
 The set of sprites (images) in this animation. Note that a sprite can hold more than 1 frame. More...
 
SPAFontMeta FontMeta
 Font meta, if this is being used as a font. More...
 
Dictionary< int, SPAMapEntryMap
 A map which essentially describes the location of invididual images on each frame. Used mainly when SPA's are utilised as fonts. More...
 

Static Public Attributes

static SPAInstance LastInstance
 The tail of the linked list of actively playing animations. More...
 
static SPAInstance FirstInstance
 The head of the linked list of actively playing animations. More...
 

Properties

bool HasMap [get]
 True if this SPA has a map. More...
 
SPASprite this[int id] [get]
 Gets a sprite with the given ID. More...
 

Static Private Attributes

static Dictionary< string, SPAInstances =new Dictionary<string,SPA>()
 A cache of all loaded SPA animations. If the garbage truck is active, it clears this. More...
 

Constructor & Destructor Documentation

Spa.SPA.SPA ( int  frameWidth,
int  frameHeight,
int  frameRate 
)
inline

Creates a new empty SPA animation.

Parameters
nameThe name of the animation. Used for accessing the SPA from e.g. HTML.
spriteCountThe number of sprites in this animation.
frameRateThe framerate in fps.
Spa.SPA.SPA ( string  name,
int  frameWidth,
int  frameHeight,
int  frameRate 
)
inline

Creates a new empty SPA animation.

Parameters
nameThe name of the animation. Used for accessing the SPA from e.g. HTML.
spriteCountThe number of sprites in this animation.
frameRateThe framerate in fps.
Spa.SPA.SPA ( string  name,
byte[]  binaryData 
)
inline

Creates a new SPA animation with the given name from the given binary data.

Parameters
nameThe name of the animation. Used for caching purposes so the binary doesn't have to be reloaded if the animation is displayed multiple times.
binaryDataThe raw binary data of the spa file.

Member Function Documentation

static int Spa.SPA.ActiveCount ( )
inlinestatic

Gets how many animations are actively playing.

Returns
The number of animations currently playing.
void Spa.SPA.AddToMap ( int  index,
SPAMapEntry  entry 
)
inline

Adds the given map entry to the map.

void Spa.SPA.ChangeFrameRate ( int  newRate)
inline

Changes the framerate of this animation.

static void Spa.SPA.Clear ( )
inlinestatic

Clears all active SPA animations.

void Spa.SPA.CreateSprites ( int  spriteCount,
uint  frameCount 
)
inline

Creates space for the given number of sprites which hold the given total number of frames.

Parameters
spriteCountThe number of sprites.
frameCountThe total number of frames held by the sprites.
static SPA Spa.SPA.Get ( string  name)
inlinestatic

Gets an already loaded SPA from the cache.

Returns
An SPA object if found; null otherwise.
SPACharacter Spa.SPA.GetCharacter ( int  charcode)
inline

Gets a character from this SPA, if it exists.

SPAMapEntry Spa.SPA.GetFromMap ( int  index)
inline

Gets the entry from the map. Index is most often e.g. charcode.

SPAInstance Spa.SPA.GetInstance ( )
inline

Creates a playable instance of this animation. Instances are required as the same animation could be visible multiple times.

Returns
A playable form of this animation.
SPASprite Spa.SPA.GetSprite ( int  id)
inline

Gets a sprite with the given ID.

static implicit Spa.SPA.operator SpaFormat ( SPA  spa)
inlinestatic

Implicitly converts an SPA into an SPAFormat object. Used when adding an SPA to the image cache.

static void Spa.SPA.Update ( float  deltaTime)
inlinestatic

Advances playback of any running animations and performs some garbage collection. Called by UI.Update.

Member Data Documentation

SPAInstance Spa.SPA.FirstInstance
static

The head of the linked list of actively playing animations.

SPAFontMeta Spa.SPA.FontMeta

Font meta, if this is being used as a font.

uint Spa.SPA.FrameCount

The number of frames in this animation.

int Spa.SPA.FrameHeight

The height of a frame.

int Spa.SPA.FrameRate

The frame rate in frames/second.

int Spa.SPA.FrameWidth

The width of a frame.

Dictionary<string,SPA> Spa.SPA.Instances =new Dictionary<string,SPA>()
staticprivate

A cache of all loaded SPA animations. If the garbage truck is active, it clears this.

SPAInstance Spa.SPA.LastInstance
static

The tail of the linked list of actively playing animations.

Dictionary<int,SPAMapEntry> Spa.SPA.Map

A map which essentially describes the location of invididual images on each frame. Used mainly when SPA's are utilised as fonts.

Gif.Gif Spa.SPA.ParentGif

The GIF object that this SPA is for.

SPASprite [] Spa.SPA.Sprites

The set of sprites (images) in this animation. Note that a sprite can hold more than 1 frame.

Property Documentation

bool Spa.SPA.HasMap
get

True if this SPA has a map.

SPASprite Spa.SPA.this[int id]
get

Gets a sprite with the given ID.