MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
Data Structures | Public Member Functions
gdl::SpriteSet Class Reference

Sprite set handling class. More...

#include <mgdl-wii-sprites.h>

Public Member Functions

 SpriteSet ()
 Constructor.
 
virtual ~SpriteSet ()
 Deconstructor.
 
bool LoadSprites (const char *fileName, const char *sheetsDir, u_int filterMode, u_int format)
 Loads a sprite set file.
 
bool LoadSprites (short spritesPerRow, short spriteHeight, ImageWii *spriteSheet)
 Loads a sprite set from image and configuration.
 
short NumSprites ()
 Returns the number of sprites in the currently loaded sprite set.
 
const SpriteSpriteInfo (short index)
 Returns a pointer to a sprite entry object.
 
void Put (short x, short y, int index, u_int col, short cx=0, short cy=0, float scale=1.f, float angle=0.f)
 Draws a sprite onto the screen.
 
void PutS (short x1, short y1, short x2, short y2, short index, u_int col)
 Draws a sprite as a stretchable rectangle.
 

Detailed Description

Sprite set handling class.

Instead of using several Image objects for handling sprite images, it is recommended to use this SpriteSet class as it allows you to store sprites as sprite sheets which is more efficient than having multiple texture objects for each individual sprite. It also allows you to reference each sprite by index making sprite animations flexible to do.

Constructor & Destructor Documentation

◆ ~SpriteSet()

gdl::SpriteSet::~SpriteSet ( )
virtual

Deconstructor.

If a sprite set and its associated sheets have already been loaded, all of it is automatically freed once the object has been deconstructed.

Member Function Documentation

◆ LoadSprites() [1/2]

bool gdl::SpriteSet::LoadSprites ( const char *  fileName,
const char *  sheetsDir,
u_int  filterMode,
u_int  format 
)

Loads a sprite set file.

Loads a TR-Engine format sprite map file and its associated sprite sheets (sprite sheets must be in PNG format in this port of the library).

Parameters
[in]*fileNameFile name of TSM file to load.
[in]*sheetsDirPath to where the associated sprite sheets are stored.
[in]filterModeFiltering mode (see TextureFilterModes).
[in]formatTexture format to load sprite sheets as (see TextureFormatModes).
Returns
Non-zero if the sprite set and its associated sprite sheets were loaded successfully. Otherwise an error occurred (detailed error is printed in console mode).

◆ LoadSprites() [2/2]

bool gdl::SpriteSet::LoadSprites ( short  spritesPerRow,
short  spriteHeight,
ImageWii spriteSheet 
)

Loads a sprite set from image and configuration.

Loads a TR-Engine format sprite map file and its associated sprite sheets (sprite sheets must be in PNG format in this port of the library).

Parameters
[in]spritesPerRowHow many sprites on a row.
[in]spriteHeightHeight of a sprite in pixels
[in]spriteSheetPointer to SpriteSheet
[in]filterModeFiltering mode (see TextureFilterModes).
[in]formatTexture format to load sprite sheets as (see TextureFormatModes).
Returns
Non-zero if the sprite set and its associated sprite sheets were loaded successfully. Otherwise an error occurred (detailed error is printed in console mode).

◆ NumSprites()

short gdl::SpriteSet::NumSprites ( )

Returns the number of sprites in the currently loaded sprite set.

Returns
The number of sprites in the sprite set, 0 if a sprite set is not loaded.

◆ Put()

void gdl::SpriteSet::Put ( short  x,
short  y,
int  index,
u_int  col,
short  cx = 0,
short  cy = 0,
float  scale = 1.f,
float  angle = 0.f 
)

Draws a sprite onto the screen.

Draws the image with color translation and optional rotation and scaling. This function must only be called between a PrepDisplay() and Display() pair. If no sprite set is loaded in this class, nothing is drawn.

Parameters
[in]xX coordinate of image.
[in]yY coordinate of image.
[in]indexIndex of sprite to draw.
[in]colColor of image (use Color::White or full white or RGBA() for normal colors).
[in]cxX offset of image pivot (you can also use one of the AlignmentModes).
[in]cyY offset of image pivot (you can also use one of the AlignmentModes).
[in]scaleScale of image (1.0f is original size).
[in]angleRotation angle in degrees.

◆ PutS()

void gdl::SpriteSet::PutS ( short  x1,
short  y1,
short  x2,
short  y2,
short  index,
u_int  col 
)

Draws a sprite as a stretchable rectangle.

Draws the image as a fully stretchable rectangle with optional color translation. This function must only be called between a PrepDisplay() and Display() pair and if no image is loaded in this class, nothing is drawn.

Parameters
[in]x1Upper-left X coordinate of image.
[in]y1Upper-left Y coordinate of image.
[in]x2Lower-right X coordinate of image.
[in]y2Lower-right Y coordinate of image.
[in]indexIndex of sprite to draw.
[in]colColor of sprite (use Colors::White for normal colors).

◆ SpriteInfo()

const gdl::Sprite * gdl::SpriteSet::SpriteInfo ( short  index)

Returns a pointer to a sprite entry object.

Parameters
[in]indexSprite index.
Returns
Pointer to a sprite entry object.

The documentation for this class was generated from the following files: