2.15.1
Functions
Spriteset

Spriteset resources management for sprites. More...

Description

Spriteset resources management for sprites.

Functions

TLN_Spriteset TLN_CreateSpriteset (TLN_Bitmap bitmap, TLN_SpriteData *data, int num_entries)
 Creates a new spriteset. More...
 
TLN_Spriteset TLN_LoadSpriteset (const char *name)
 Loads a spriteset from an image png and its associated atlas descriptor. More...
 
TLN_Spriteset TLN_CloneSpriteset (TLN_Spriteset src)
 Creates a duplicate of the specified spriteset and its associated palette. More...
 
bool TLN_GetSpriteInfo (TLN_Spriteset spriteset, int entry, TLN_SpriteInfo *info)
 Query the details about the specified sprite inside a spriteset. More...
 
TLN_Palette TLN_GetSpritesetPalette (TLN_Spriteset spriteset)
 Returns a reference to the palette associated to the specified spriteset. More...
 
int TLN_FindSpritesetSprite (TLN_Spriteset spriteset, const char *name)
 Returns a reference to the palette associated to the specified spriteset. More...
 
bool TLN_SetSpritesetData (TLN_Spriteset spriteset, int entry, TLN_SpriteData *data, void *pixels, int pitch)
 Sets attributes and pixels of a given sprite inside a spriteset. More...
 
bool TLN_DeleteSpriteset (TLN_Spriteset Spriteset)
 Deletes the specified spriteset and frees memory. More...
 

Function Documentation

◆ TLN_CreateSpriteset()

TLN_Spriteset TLN_CreateSpriteset ( TLN_Bitmap  bitmap,
TLN_SpriteData data,
int  num_entries 
)

Creates a new spriteset.

Parameters
bitmapBitmap containing the sprite graphics
dataArray of TLN_SpriteData structures with sprite descriptions
num_entriesNumber of entries in data[] array
Returns
Reference to the created spriteset, or NULL if error
See also
TLN_DeleteSpriteset()

◆ TLN_LoadSpriteset()

TLN_Spriteset TLN_LoadSpriteset ( const char *  name)

Loads a spriteset from an image png and its associated atlas descriptor.

Parameters
nameBase name of the files containing the spriteset, with or without .png extension
Returns
Reference to the newly loaded spriteset or NULL if error
Remarks
The spriteset comes in a pair of files: an image file (bmp or png) and a standarized atlas descriptor (json, csv or txt) The supported json format is the array.

◆ TLN_CloneSpriteset()

TLN_Spriteset TLN_CloneSpriteset ( TLN_Spriteset  src)

Creates a duplicate of the specified spriteset and its associated palette.

Parameters
srcSpriteset to clone
Returns
A reference to the newly cloned spriteset, or NULL if error
See also
TLN_LoadSpriteset()

◆ TLN_GetSpriteInfo()

bool TLN_GetSpriteInfo ( TLN_Spriteset  spriteset,
int  entry,
TLN_SpriteInfo info 
)

Query the details about the specified sprite inside a spriteset.

Parameters
spritesetReference to the spriteset to get info about
entryThe entry index inside the spriteset [0, num_sprites - 1]
infoPointer to application-allocated TLN_SpriteInfo structure that will receive the data
Returns
true if success or false if error

◆ TLN_GetSpritesetPalette()

TLN_Palette TLN_GetSpritesetPalette ( TLN_Spriteset  spriteset)

Returns a reference to the palette associated to the specified spriteset.

Parameters
spritesetSpriteset to obtain the palette
Remarks
The palette of a spriteset is created at load time and cannot be modified. When TLN_ConfigSprite function is used to setup a sprite, the palette associated with the specified spriteset is automatically assigned to that sprite, but it can be later replaced with TLN_SetSpritePalette
See also
TLN_SetSpritePalette()

◆ TLN_FindSpritesetSprite()

int TLN_FindSpritesetSprite ( TLN_Spriteset  spriteset,
const char *  name 
)

Returns a reference to the palette associated to the specified spriteset.

Parameters
spritesetSpriteset where to find the sprite
nameName of the sprite to findo
Returns
sprite index (0 -> num_sprites - 1) if found, or -1 if not found

◆ TLN_SetSpritesetData()

bool TLN_SetSpritesetData ( TLN_Spriteset  spriteset,
int  entry,
TLN_SpriteData data,
void *  pixels,
int  pitch 
)

Sets attributes and pixels of a given sprite inside a spriteset.

Parameters
spritesetSpriteset to set the data
entryThe entry index inside the spriteset to modify [0, num_sprites - 1]
dataPointer to a user-provided TLN_SpriteData structure with sprite description
pixelsPointer to source pixel data
pitchNumber of bytes per scanline of the source pixel data
See also
TLN_CreateSpriteset()

◆ TLN_DeleteSpriteset()

bool TLN_DeleteSpriteset ( TLN_Spriteset  spriteset)

Deletes the specified spriteset and frees memory.

Parameters
spritesetSpriteset to delete
Remarks
Don't delete a spriteset currently attached to a sprite!
See also
TLN_LoadSpriteset(), TLN_CloneSpriteset()