SpriteSheet Module
Functions for creating sprite sheets from various sources.
These are factory functions intended for use at initialization time. Allocations are acceptable here as sheets are typically created once.
Functions and values
| Function or value |
Description
|
|
|
Full Usage:
fromFrames texture origin animations
Parameters:
Texture2D
-
The texture atlas.
origin : Vector2
-
Origin point for drawing (typically center of frame).
animations : (string * Animation)[]
-
Array of (name, animation) struct tuples.
Returns: SpriteSheet
|
Create a sprite sheet from explicit frame rectangles. This is the most flexible constructor - use this when you've already parsed animation data from any format (TexturePacker, Aseprite, custom).
|
Full Usage:
fromGrid texture frameWidth frameHeight columns animations
Parameters:
Texture2D
-
The texture atlas.
frameWidth : int
-
Width of each frame in pixels.
frameHeight : int
-
Height of each frame in pixels.
columns : int
-
Number of columns in the sprite sheet.
animations : GridAnimationDef[]
-
Array of GridAnimationDef records.
Returns: SpriteSheet
|
Create a sprite sheet from a uniform grid layout. Use this for sprite sheets where all frames are the same size arranged in a grid (common for retro-style games).
|
|
Create a single-animation sprite sheet. Convenience function for simple sprites with just one animation (e.g., a spinning coin, flickering torch).
|
|
Create a sprite sheet for a single static frame (no animation).
|
Full Usage:
tryGetAnimationIndex name sheet
Parameters:
string
sheet : SpriteSheet
Returns: int voption
Modifiers: inline |
Try to get the index for an animation name. Use this at load time to resolve animation names to indices, then use index-based playback during gameplay for zero allocations.
|
Full Usage:
withNormalMap nm sheet
Parameters:
Texture2D
sheet : SpriteSheet
Returns: SpriteSheet
|
Add a normal map to an existing sprite sheet.
|
Mibo