Functions
Spriteset

Spriteset resources management for sprites. More...

Description

Functions

TLNAPI TLN_Spriteset TLN_CreateSpriteset (TLN_Bitmap bitmap, TLN_SpriteData *data, int num_entries)
 Creates a new spriteset. More...
 
TLNAPI TLN_Spriteset TLN_LoadSpriteset (const char *name)
 Loads a spriteset from a png/txt file pair. More...
 
TLNAPI TLN_Spriteset TLN_CloneSpriteset (TLN_Spriteset src)
 Creates a duplicate of the specified spriteset and its associated palette. More...
 
TLNAPI bool TLN_GetSpriteInfo (TLN_Spriteset spriteset, int entry, TLN_SpriteInfo *info)
 Query the details about the specified sprite inside a spriteset. More...
 
TLNAPI TLN_Palette TLN_GetSpritesetPalette (TLN_Spriteset spriteset)
 Returns a reference to the palette associated to the specified spriteset. More...
 
TLNAPI int TLN_FindSpritesetSprite (TLN_Spriteset spriteset, char *name)
 Returns a reference to the palette associated to the specified spriteset. More...
 
TLNAPI 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...
 
TLNAPI bool TLN_DeleteSpriteset (TLN_Spriteset Spriteset)
 Deletes the specified spriteset and frees memory. More...
 

Function Documentation

TLNAPI TLN_Spriteset TLN_CreateSpriteset ( TLN_Bitmap  bitmap,
TLN_SpriteData data,
int  num_entries 
)
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()
TLNAPI TLN_Spriteset TLN_LoadSpriteset ( const char *  name)
Parameters
nameBase name of the files containing the spriteset
Returns
Reference to the newly loaded spriteset or NULL if error
Remarks
The spriteset comes in a pair of files called name.png and name.txt. The png file contains the spriteset, whereas the txt contains the coordinates of the rectangles that define individual sprites. These files can be created wit the spritesheet packer tool (http://spritesheetpacker.codeplex.com/)
An associated palette is also created, it can be obtained calling TLN_GetSpritesetPalette()
TLNAPI TLN_Spriteset TLN_CloneSpriteset ( TLN_Spriteset  src)
Parameters
srcSpriteset to clone
Returns
A reference to the newly cloned spriteset, or NULL if error
See also
TLN_LoadSpriteset()
TLNAPI bool TLN_GetSpriteInfo ( TLN_Spriteset  spriteset,
int  entry,
TLN_SpriteInfo info 
)
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
TLNAPI TLN_Palette TLN_GetSpritesetPalette ( TLN_Spriteset  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()
TLNAPI int TLN_FindSpritesetSprite ( TLN_Spriteset  spriteset,
char *  name 
)
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
TLNAPI bool TLN_SetSpritesetData ( TLN_Spriteset  spriteset,
int  entry,
TLN_SpriteData data,
void *  pixels,
int  pitch 
)
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()
TLNAPI bool TLN_DeleteSpriteset ( TLN_Spriteset  spriteset)
Parameters
spritesetSpriteset to delete
Remarks
Don't delete a spriteset currently attached to a sprite!
See also
TLN_LoadSpriteset(), TLN_CloneSpriteset()