#include <TileSet.h>
Public Member Functions | |
void | setTileSource (unsigned int column, unsigned int row, const Vector2 &source) |
void | getTileSource (unsigned int column, unsigned int row, Vector2 *source) |
float | getTileWidth () const |
float | getTileHeight () const |
unsigned int | getRowCount () const |
unsigned int | getColumnCount () const |
float | getWidth () const |
float | getHeight () const |
void | setOpacity (float opacity) |
float | getOpacity () const |
void | setColor (const Vector4 &color) |
const Vector4 & | getColor () const |
unsigned int | draw (bool wireframe=false) |
Static Public Member Functions | |
static TileSet * | create (const char *imagePath, float tileWidth, float tileHeight, unsigned int rowCount, unsigned int columnCount) |
static TileSet * | create (Properties *properties) |
Protected Member Functions | |
TileSet () | |
~TileSet () | |
TileSet & | operator= (const TileSet &set) |
Drawable * | clone (NodeCloneContext &context) |
Defines a grid of tiles for rendering a 2D planer region.
The UVs are sourced from the texture atlas image. The columns(x) and rows(y) are set individually for each in the tile set. Specifying a source (x,y) of -1, -1 will allow for tiles in the set to be empty. The size of all the tiles must be equal to the tileWidth/tileHeight provided.
To avoid seams in the tiles the tile should be padded with a gutter of duplicate pixels on each side of the region.
The tile set does not support rotation or scaling.
gameplay::TileSet::TileSet | ( | ) | [protected] |
Constructor
gameplay::TileSet::~TileSet | ( | ) | [protected] |
Destructor
Drawable* gameplay::TileSet::clone | ( | NodeCloneContext & | context | ) | [protected, virtual] |
Implements gameplay::Drawable.
static TileSet* gameplay::TileSet::create | ( | const char * | imagePath, |
float | tileWidth, | ||
float | tileHeight, | ||
unsigned int | rowCount, | ||
unsigned int | columnCount | ||
) | [static] |
Creates a tile set.
imagePath | The path to the image to create the sprite from. |
tileWidth | The width of each tile in the tile set. |
tileHeight | The height of each tile in the tile set. |
rowCount | The number of tile rows. |
columnCount | The number of tile columns. |
static TileSet* gameplay::TileSet::create | ( | Properties * | properties | ) | [static] |
Creates a tile set from a properties object.
properties | The properties object to load from. |
unsigned int gameplay::TileSet::draw | ( | bool | wireframe = false | ) | [virtual] |
Implements gameplay::Drawable.
const Vector4& gameplay::TileSet::getColor | ( | ) | const |
Gets the color (RGBA) for the sprite.
unsigned int gameplay::TileSet::getColumnCount | ( | ) | const |
Gets the number of tile columns.
float gameplay::TileSet::getHeight | ( | ) | const |
Gets the overall width of the tileset.
float gameplay::TileSet::getOpacity | ( | ) | const |
Gets the opacity for the sprite.
The range is from full transparent to opaque [0.0,1.0].
unsigned int gameplay::TileSet::getRowCount | ( | ) | const |
Gets the number of tile rows.
float gameplay::TileSet::getTileHeight | ( | ) | const |
Gets the height of each tile in the tile set.
void gameplay::TileSet::getTileSource | ( | unsigned int | column, |
unsigned int | row, | ||
Vector2 * | source | ||
) |
Gets the source clip region and flip flags for the specified column and row.
column | The column to get the source clip region and flip flags for. |
row | The row to specify the source clip region and flip flags for. |
source | The source region to be returned back. |
float gameplay::TileSet::getTileWidth | ( | ) | const |
Gets the width of each tile in the tile set.
float gameplay::TileSet::getWidth | ( | ) | const |
Gets the overall width of the tileset.
void gameplay::TileSet::setColor | ( | const Vector4 & | color | ) |
Sets the color (RGBA) for the sprite.
color | The color(RGBA) for the sprite. |
void gameplay::TileSet::setOpacity | ( | float | opacity | ) |
Sets the opacity for the sprite.
The range is from full transparent to opaque [0.0,1.0].
opacity | The opacity for the sprite. |
void gameplay::TileSet::setTileSource | ( | unsigned int | column, |
unsigned int | row, | ||
const Vector2 & | source | ||
) |
Sets the tile source location for the specified column and row.
column | The column to set the source for. |
row | The row to set the source for. |
source | The source top-left corner where the tile is positioned. |