|
MTek-GDL 0.100.4-muffintrap
|
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 Sprite * | SpriteInfo (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. | |
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.
|
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.
| 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).
| [in] | *fileName | File name of TSM file to load. |
| [in] | *sheetsDir | Path to where the associated sprite sheets are stored. |
| [in] | filterMode | Filtering mode (see TextureFilterModes). |
| [in] | format | Texture format to load sprite sheets as (see TextureFormatModes). |
| 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).
| [in] | spritesPerRow | How many sprites on a row. |
| [in] | spriteHeight | Height of a sprite in pixels |
| [in] | spriteSheet | Pointer to SpriteSheet |
| [in] | filterMode | Filtering mode (see TextureFilterModes). |
| [in] | format | Texture format to load sprite sheets as (see TextureFormatModes). |
| short gdl::SpriteSet::NumSprites | ( | ) |
Returns the number of sprites in the currently loaded sprite set.
| 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.
| [in] | x | X coordinate of image. |
| [in] | y | Y coordinate of image. |
| [in] | index | Index of sprite to draw. |
| [in] | col | Color of image (use Color::White or full white or RGBA() for normal colors). |
| [in] | cx | X offset of image pivot (you can also use one of the AlignmentModes). |
| [in] | cy | Y offset of image pivot (you can also use one of the AlignmentModes). |
| [in] | scale | Scale of image (1.0f is original size). |
| [in] | angle | Rotation angle in degrees. |
| 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.
| [in] | x1 | Upper-left X coordinate of image. |
| [in] | y1 | Upper-left Y coordinate of image. |
| [in] | x2 | Lower-right X coordinate of image. |
| [in] | y2 | Lower-right Y coordinate of image. |
| [in] | index | Index of sprite to draw. |
| [in] | col | Color of sprite (use Colors::White for normal colors). |
| const gdl::Sprite * gdl::SpriteSet::SpriteInfo | ( | short | index | ) |
Returns a pointer to a sprite entry object.
| [in] | index | Sprite index. |