Sprite Definition¶
2D images. One sprite archive holds several frames that share a palette and a canvas size, so decoding one gives an array.
SpriteDefinition.Create¶
function TSpriteDefinition.Create(id: Integer; const data: TByteArray): TSpriteDefinitionArray; static;
Decodes a sprite archive into its frames. One archive holds several frames sharing a palette and a common canvas size, which is why this returns an array.
The archive is read back to front: the frame count is the last two bytes, the frame headers sit
above it and the palette above those, leaving the pixel data at the front. Each frame’s pixels
are palette indices, stored either row by row or column by column depending on its flags, and
index 0 is transparent - so alpha is only read when a frame says it has any, and any pixel
that is not index 0 is opaque regardless.
SpriteDefinition.ToImage¶
function TSpriteDefinition.ToImage(): TImage;
The frame as an image, at its own size rather than the archive’s canvas size.
TSpriteDefinitionArray.IndexOf¶
function TSpriteDefinitionArray.IndexOf(id: Integer): Integer;
The position of id in the array, or -1 if there is no such sprite.
Sprite definitions are stored one per id with no gaps, so an id is its own index; this exists to keep that assumption in one place.