2.15.1
Functions
Tileset

Tileset resources management for background layers. More...

Description

Tileset resources management for background layers.

Functions

TLN_Tileset TLN_CreateTileset (int numtiles, int width, int height, TLN_Palette palette, TLN_SequencePack sp, TLN_TileAttributes *attributes)
 Creates a tile-based tileset. More...
 
TLN_Tileset TLN_CreateImageTileset (int numtiles, TLN_TileImage *images)
 Creates a multiple image-based tileset. More...
 
TLN_Tileset TLN_LoadTileset (const char *filename)
 Loads a tileset from a Tiled .tsx file. More...
 
TLN_Tileset TLN_CloneTileset (TLN_Tileset src)
 Creates a duplicate of the specified tileset and its associated palette. More...
 
bool TLN_SetTilesetPixels (TLN_Tileset tileset, int entry, uint8_t *srcdata, int srcpitch)
 Sets pixel data for a tile in a tile-based tileset. More...
 
int TLN_GetTileWidth (TLN_Tileset tileset)
 Returns the width in pixels of each individual tile in the tileset. More...
 
int TLN_GetTileHeight (TLN_Tileset tileset)
 Returns the height in pixels of each individual tile in the tileset. More...
 
int TLN_GetTilesetNumTiles (TLN_Tileset tileset)
 Returns the number of different tiles in tileset. More...
 
TLN_Palette TLN_GetTilesetPalette (TLN_Tileset tileset)
 Returns a reference to the palette associated to the specified tileset. More...
 
TLN_SequencePack TLN_GetTilesetSequencePack (TLN_Tileset tileset)
 Returns a reference to the optional sequence pack associated to the specified tileset. More...
 
bool TLN_DeleteTileset (TLN_Tileset tileset)
 Deletes the specified tileset and frees memory. More...
 

Function Documentation

◆ TLN_CreateTileset()

TLN_Tileset TLN_CreateTileset ( int  numtiles,
int  width,
int  height,
TLN_Palette  palette,
TLN_SequencePack  sp,
TLN_TileAttributes attributes 
)

Creates a tile-based tileset.

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()

◆ TLN_CreateImageTileset()

TLN_Tileset TLN_CreateImageTileset ( int  numtiles,
TLN_TileImage images 
)

Creates a multiple image-based tileset.

Parameters
numtilesNumber of tiles that the tileset will hold
imagesArray of image structures, one for each tile. Can be NULL
Returns
Reference to the created tileset, or NULL if error

◆ TLN_LoadTileset()

TLN_Tileset TLN_LoadTileset ( const char *  filename)

Loads a tileset from a Tiled .tsx file.

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()

◆ TLN_CloneTileset()

TLN_Tileset TLN_CloneTileset ( TLN_Tileset  src)

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

Parameters
srcTileset to clone
Returns
A reference to the newly cloned tileset, or NULL if error
See also
TLN_LoadTileset()

◆ TLN_SetTilesetPixels()

bool TLN_SetTilesetPixels ( TLN_Tileset  tileset,
int  entry,
uint8_t *  srcdata,
int  srcpitch 
)

Sets pixel data for a tile in a tile-based tileset.

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()

◆ TLN_GetTileWidth()

int TLN_GetTileWidth ( TLN_Tileset  tileset)

Returns the width in pixels of each individual tile in the tileset.

Parameters
tilesetReference to the tileset to get info from
See also
TLN_GetTileHeight()

◆ TLN_GetTileHeight()

int TLN_GetTileHeight ( TLN_Tileset  tileset)

Returns the height in pixels of each individual tile in the tileset.

Parameters
tilesetReference to the tileset to get info from
See also
TLN_GetTileWidth()

◆ TLN_GetTilesetNumTiles()

int TLN_GetTilesetNumTiles ( TLN_Tileset  tileset)

Returns the number of different tiles in tileset.

Parameters
tilesetReference to the tileset to get info from

◆ TLN_GetTilesetPalette()

TLN_Palette TLN_GetTilesetPalette ( TLN_Tileset  tileset)

Returns a reference to the palette associated to the specified 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()

◆ TLN_GetTilesetSequencePack()

TLN_SequencePack TLN_GetTilesetSequencePack ( TLN_Tileset  tileset)

Returns a reference to the optional sequence pack associated to the specified tileset.

Parameters
tilesetReference to the tileset to get the palette
See also
TLN_LoadTileset(), TLN_CreateTileset()

◆ TLN_DeleteTileset()

bool TLN_DeleteTileset ( TLN_Tileset  tileset)

Deletes the specified tileset and frees memory.

Parameters
tilesetTileset to delete
Remarks
Don't delete a tileset currently attached to a layer!
See also
TLN_LoadTileset(), TLN_CloneTileset()