libtmx  0.4.0
an C++11 library for reading TMX files
Public Types | Public Member Functions | List of all members
tmx::TileSet Class Reference

A tileset is a set of tiles in a single file (image or TSX file). More...

#include <tmx/TileSet.h>

Inheritance diagram for tmx::TileSet:
Inheritance graph
[legend]

Public Types

typedef boost::transformed_range< Adaptor, const boost::iterator_range< std::vector< std::unique_ptr< Terrain > >::const_iterator > > const_terrain_range
 A terrain range. More...
 
typedef boost::transform_iterator< Adaptor, std::vector< std::unique_ptr< Tile > >::const_iteratorconst_iterator
 A tile iterator. More...
 

Public Member Functions

 TileSet (unsigned firstgid, const std::string &name, unsigned tilewidth, unsigned tileheight, unsigned spacing, unsigned margin, unsigned tilecount)
 TileSet constructor. More...
 
Properties
unsigned getFirstGID () const noexcept
 Get the first global id of this tileset. More...
 
const std::string & getName () const noexcept
 Get the name of the tileset. More...
 
unsigned getTileWidth () const noexcept
 Get the width of the tiles. More...
 
unsigned getTileHeight () const noexcept
 Get the height of the tiles. More...
 
unsigned getSpacing () const noexcept
 Get the spacing between tiles. More...
 
unsigned getMargin () const noexcept
 Get the margin around tiles. More...
 
unsigned getTileCount () const noexcept
 Get the tile count. More...
 
void setOffset (int x, int y) noexcept
 Set the offset of the tileset. More...
 
int getOffsetX () const noexcept
 Get the x offset of the tileset. More...
 
int getOffsetY () const noexcept
 Get the y offset of the tileset. More...
 
Image handing
void setImage (std::unique_ptr< Image > image)
 Set an image associated to the tileset. More...
 
bool hasImage () const noexcept
 Tell whether the tileset has an image. More...
 
const ImagegetImage () const noexcept
 Get the image associated to the tileset. More...
 
Terrain handling
void addTerrain (std::unique_ptr< Terrain > terrain)
 Add terrain information to the tileset. More...
 
const_terrain_range getTerrains () const noexcept
 Get the terrains. More...
 
Tile handling
void addTile (std::unique_ptr< Tile > tile)
 Add a tile to the tileset. More...
 
const_iterator begin () const noexcept
 Get the begin iterator on the tiles. More...
 
const_iterator end () const noexcept
 Get the end iterator on the tiles. More...
 
const TilegetTile (unsigned id) const noexcept
 Get the tile corresponding to an id. More...
 
Rect getCoords (unsigned id, Size size) const noexcept
 Get the coordinates of a tile corresponding to an id. More...
 
- Public Member Functions inherited from tmx::Component
bool hasProperty (const std::string &key) const noexcept
 Tell if the object has a given property. More...
 
const std::string & getProperty (const std::string &key, const std::string &def) const noexcept
 Get a property value. More...
 
bool addProperty (const std::string &key, const std::string &value)
 Add a property. More...
 

Detailed Description

A tileset is a set of tiles in a single file (image or TSX file).

Member Typedef Documentation

typedef boost::transform_iterator<Adaptor, std::vector<std::unique_ptr<Tile> >::const_iterator> tmx::TileSet::const_iterator

A tile iterator.

typedef boost::transformed_range<Adaptor, const boost::iterator_range<std::vector<std::unique_ptr<Terrain> >::const_iterator> > tmx::TileSet::const_terrain_range

A terrain range.

Constructor & Destructor Documentation

tmx::TileSet::TileSet ( unsigned  firstgid,
const std::string &  name,
unsigned  tilewidth,
unsigned  tileheight,
unsigned  spacing,
unsigned  margin,
unsigned  tilecount 
)
inline

TileSet constructor.

Member Function Documentation

void tmx::TileSet::addTerrain ( std::unique_ptr< Terrain terrain)
inline

Add terrain information to the tileset.

Parameters
terrainthe terrain information
void tmx::TileSet::addTile ( std::unique_ptr< Tile tile)
inline

Add a tile to the tileset.

Parameters
tilethe tile
const_iterator tmx::TileSet::begin ( ) const
inlinenoexcept

Get the begin iterator on the tiles.

Returns
the begin iterator on the tiles
const_iterator tmx::TileSet::end ( ) const
inlinenoexcept

Get the end iterator on the tiles.

Returns
the end iterator on the tiles
Rect tmx::TileSet::getCoords ( unsigned  id,
Size  size 
) const
noexcept

Get the coordinates of a tile corresponding to an id.

Parameters
idthe id of the tile
sizethe size of the image corresponding to the tile
Returns
the coordinates in the form of a rectangle
unsigned tmx::TileSet::getFirstGID ( ) const
inlinenoexcept

Get the first global id of this tileset.

Returns
the first global id of the tileset
const Image* tmx::TileSet::getImage ( ) const
inlinenoexcept

Get the image associated to the tileset.

Returns
the image associated to the tileset
unsigned tmx::TileSet::getMargin ( ) const
inlinenoexcept

Get the margin around tiles.

Returns
the margin around tiles (in pixels)
const std::string& tmx::TileSet::getName ( ) const
inlinenoexcept

Get the name of the tileset.

Returns
the name of the tileset
int tmx::TileSet::getOffsetX ( ) const
inlinenoexcept

Get the x offset of the tileset.

Returns
the x offset of the tileset (in pixels)
int tmx::TileSet::getOffsetY ( ) const
inlinenoexcept

Get the y offset of the tileset.

Returns
the y offset of the tileset (in pixels)
unsigned tmx::TileSet::getSpacing ( ) const
inlinenoexcept

Get the spacing between tiles.

Returns
the spacing between tiles (in pixels)
const_terrain_range tmx::TileSet::getTerrains ( ) const
inlinenoexcept

Get the terrains.

Returns
a terrain range
const Tile* tmx::TileSet::getTile ( unsigned  id) const
noexcept

Get the tile corresponding to an id.

Parameters
idthe id of the tile
Returns
the tile
unsigned tmx::TileSet::getTileCount ( ) const
inlinenoexcept

Get the tile count.

Returns
the tile count
unsigned tmx::TileSet::getTileHeight ( ) const
inlinenoexcept

Get the height of the tiles.

Returns
the height of the tiles
unsigned tmx::TileSet::getTileWidth ( ) const
inlinenoexcept

Get the width of the tiles.

Returns
the width of the tiles
bool tmx::TileSet::hasImage ( ) const
inlinenoexcept

Tell whether the tileset has an image.

Returns
true if the tileset has an image
void tmx::TileSet::setImage ( std::unique_ptr< Image image)
inline

Set an image associated to the tileset.

Parameters
imagethe image associated to the tileset
void tmx::TileSet::setOffset ( int  x,
int  y 
)
inlinenoexcept

Set the offset of the tileset.

Parameters
xthe x coordinate of the offset
ythe y coordinate of the offset