Functions
Tileset

Tileset resources management for background layers. More...

Description

Functions

TLNAPI TLN_Tileset TLN_CreateTileset (int numtiles, int width, int height, TLN_Palette palette, TLN_SequencePack sp, TLN_TileAttributes *attributes)
 Creates a new tileset. More...
 
TLNAPI TLN_Tileset TLN_LoadTileset (const char *filename)
 Loads a tileset from a Tiled .tsx file. More...
 
TLNAPI TLN_Tileset TLN_CloneTileset (TLN_Tileset src)
 Creates a duplicate of the specified tileset and its associated palette. More...
 
TLNAPI bool TLN_SetTilesetPixels (TLN_Tileset tileset, int entry, uint8_t *srcdata, int srcpitch)
 Sets pixel data for a tile in a tileset. More...
 
TLNAPI bool TLN_CopyTile (TLN_Tileset tileset, int src, int dst)
 Copies tile graphic data inside a Tileset specified tileset. More...
 
TLNAPI int TLN_GetTileWidth (TLN_Tileset tileset)
 Returns the width in pixels of each individual tile in the tileset. More...
 
TLNAPI int TLN_GetTileHeight (TLN_Tileset tileset)
 Returns the height in pixels of each individual tile in the tileset. More...
 
TLNAPI TLN_Palette TLN_GetTilesetPalette (TLN_Tileset tileset)
 Returns a reference to the palette associated to the specified tileset. More...
 
TLNAPI TLN_SequencePack TLN_GetTilesetSequencePack (TLN_Tileset tileset)
 Returns a reference to the optional sequence pack associated to the specified tileset. More...
 
TLNAPI bool TLN_DeleteTileset (TLN_Tileset tileset)
 Deletes the specified tileset and frees memory. More...
 

Function Documentation

TLNAPI TLN_Tileset TLN_CreateTileset ( int  numtiles,
int  width,
int  height,
TLN_Palette  palette,
TLN_SequencePack  sp,
TLN_TileAttributes attributes 
)
Parameters
numtilesNumber of tiles that the tileset will hold
widthWidth of each tile (must be multiple of 8)
heightHeight of each tile (must be multiple of 8)
paletteReference to the palette to assign
spOptional reference to the optional sequence pack with associated tileset animations, can be NULL
attributesOptional array of attributes, one for each tile. Can be NULL
Returns
Reference to the created tileset, or NULL if error
See also
TLN_SetTilesetPixels()
TLNAPI TLN_Tileset TLN_LoadTileset ( const char *  filename)
Parameters
filenameTSX file to load
Returns
Reference to the newly loaded tileset or NULL if error
Remarks
An associated palette is also created, it can be obtained calling TLN_GetTilesetPalette()
TLNAPI TLN_Tileset TLN_CloneTileset ( TLN_Tileset  src)
Parameters
srcTileset to clone
Returns
A reference to the newly cloned tileset, or NULL if error
See also
TLN_LoadTileset()
TLNAPI bool TLN_SetTilesetPixels ( TLN_Tileset  tileset,
int  entry,
uint8_t *  srcdata,
int  srcpitch 
)
Parameters
tilesetReference to the tileset
entryNumber of tile to set [0, num_tiles - 1]
srcdataPointer to pixel data to set
srcpitchBytes per line of source data
Returns
true if success, or false if error
Remarks
Care must be taken in providing pixel data and pitch as it can crash the aplication
See also
TLN_CreateTileset()
TLNAPI bool TLN_CopyTile ( TLN_Tileset  tileset,
int  src,
int  dst 
)
Parameters
tilesetReference to the tileset to get the palette
srcindex of source tile
dstindex of target tile
TLNAPI int TLN_GetTileWidth ( TLN_Tileset  tileset)
Parameters
tilesetReference to the tileset to get info from
See also
TLN_GetTileHeight()
TLNAPI int TLN_GetTileHeight ( TLN_Tileset  tileset)
Parameters
tilesetReference to the tileset to get info from
See also
TLN_GetTileWidth()
TLNAPI TLN_Palette TLN_GetTilesetPalette ( TLN_Tileset  tileset)
Parameters
tilesetReference to the tileset to get the palette
Remarks
The palette of a tileset is created at load time and cannot be modified. When TLN_SetLayer function is used to attach a tileset to a layer, the palette associated with the specified tileset is automatically assigned to that layer, but it can be later replaced with TLN_SetLayerPalette
See also
TLN_LoadTileset(), TLN_SetLayerPalette()
TLNAPI TLN_SequencePack TLN_GetTilesetSequencePack ( TLN_Tileset  tileset)
Parameters
tilesetReference to the tileset to get the palette
See also
TLN_LoadTileset(), TLN_CreateTileset()
TLNAPI bool TLN_DeleteTileset ( TLN_Tileset  tileset)
Parameters
tilesetTileset to delete
Remarks
Don't delete a tileset currently attached to a layer!
See also
TLN_LoadTileset(), TLN_CloneTileset()