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

A map is a set of tilesets and a set of different layers. More...

#include <tmx/Map.h>

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

Public Types

typedef boost::transformed_range< Adaptor, const boost::iterator_range< std::vector< std::unique_ptr< TileSet > >::const_iterator > > const_tileset_range
 A tileset range. More...
 
typedef boost::transformed_range< Adaptor, const boost::iterator_range< std::vector< std::unique_ptr< Layer > >::const_iterator > > const_layer_range
 A layer range. More...
 

Public Member Functions

 Map (const std::string version, Orientation orientation, unsigned width, unsigned height, unsigned tilewidth, unsigned tileheight, const std::string &bgcolor, RenderOrder renderOrder, unsigned hexSideLength, StaggerAxis axis, StaggerIndex index, unsigned nextObjectId)
 Map constructor. More...
 
Properties
const std::string & getVersion () const noexcept
 Get the version of the TMX format. More...
 
Orientation getOrientation () const noexcept
 Get the orientation of the map. More...
 
unsigned getWidth () const noexcept
 Get the width of the map. More...
 
unsigned getHeight () const noexcept
 Get the height of the map. More...
 
unsigned getTileWidth () const noexcept
 Get the width of tiles. More...
 
unsigned getTileHeight () const noexcept
 Get the height of tiles. More...
 
const std::string & getBackgroundColor () const noexcept
 Get the background color. More...
 
RenderOrder getRenderOrder () const noexcept
 Get the render order. More...
 
unsigned getHexSideLength () const noexcept
 Get the hexagonal side length. More...
 
StaggerAxis getStaggerAxis () const noexcept
 Get the staggered axis. More...
 
StaggerIndex getStaggerIndex () const noexcept
 Get the staggered index. More...
 
unsigned getNextObjectId () const noexcept
 Get the next object id. More...
 
Tileset handling
void addTileSet (std::unique_ptr< TileSet > tileset)
 Add a tileset. More...
 
const_tileset_range getTileSets () const noexcept
 Get the tilesets. More...
 
const TileSetgetTileSetFromGID (unsigned gid) const noexcept
 Get the tileset corresponding to a global id. More...
 
Layer handling
void addLayer (std::unique_ptr< Layer > layer)
 Add a layer. More...
 
const_layer_range getLayers () const noexcept
 Get the layers. More...
 
void visitLayers (LayerVisitor &visitor) const
 Visit the layers with a visitor. 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...
 

Static Public Member Functions

Map parsing
static std::unique_ptr< MapparseFile (const boost::filesystem::path &filename)
 Parse a TMX file. More...
 

Detailed Description

A map is a set of tilesets and a set of different layers.

Tilesets describe what to draw while layers describe how to draw things.

Member Typedef Documentation

typedef boost::transformed_range<Adaptor, const boost::iterator_range<std::vector<std::unique_ptr<Layer> >::const_iterator> > tmx::Map::const_layer_range

A layer range.

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

A tileset range.

Constructor & Destructor Documentation

tmx::Map::Map ( const std::string  version,
Orientation  orientation,
unsigned  width,
unsigned  height,
unsigned  tilewidth,
unsigned  tileheight,
const std::string &  bgcolor,
RenderOrder  renderOrder,
unsigned  hexSideLength,
StaggerAxis  axis,
StaggerIndex  index,
unsigned  nextObjectId 
)
inline

Map constructor.

Member Function Documentation

void tmx::Map::addLayer ( std::unique_ptr< Layer layer)
inline

Add a layer.

Parameters
layerthe layer
void tmx::Map::addTileSet ( std::unique_ptr< TileSet tileset)
inline

Add a tileset.

Parameters
tilesetthe tileset
const std::string& tmx::Map::getBackgroundColor ( ) const
inlinenoexcept

Get the background color.

Returns
the background color
unsigned tmx::Map::getHeight ( ) const
inlinenoexcept

Get the height of the map.

Returns
the height of the map (in number of tiles)
unsigned tmx::Map::getHexSideLength ( ) const
inlinenoexcept

Get the hexagonal side length.

Only relevant for hexagonal maps.

Returns
the hexagonal side length
const_layer_range tmx::Map::getLayers ( ) const
inlinenoexcept

Get the layers.

Returns
a layer range
unsigned tmx::Map::getNextObjectId ( ) const
inlinenoexcept

Get the next object id.

Returns
the next object id.
Orientation tmx::Map::getOrientation ( ) const
inlinenoexcept

Get the orientation of the map.

Returns
the orientation of the map
RenderOrder tmx::Map::getRenderOrder ( ) const
inlinenoexcept

Get the render order.

Returns
the render order
StaggerAxis tmx::Map::getStaggerAxis ( ) const
inlinenoexcept

Get the staggered axis.

Only relevant for staggered and hexagonal maps.

Returns
the staggered axis
StaggerIndex tmx::Map::getStaggerIndex ( ) const
inlinenoexcept

Get the staggered index.

Only relevant for staggered and hexagonal maps.

Returns
the staggered index
unsigned tmx::Map::getTileHeight ( ) const
inlinenoexcept

Get the height of tiles.

Returns
the height of tiles (in pixels)
const TileSet* tmx::Map::getTileSetFromGID ( unsigned  gid) const
noexcept

Get the tileset corresponding to a global id.

Parameters
gida global id
Returns
the corresponding tileset
const_tileset_range tmx::Map::getTileSets ( ) const
inlinenoexcept

Get the tilesets.

Returns
a tileset range
unsigned tmx::Map::getTileWidth ( ) const
inlinenoexcept

Get the width of tiles.

Returns
the width of tiles (in pixels)
const std::string& tmx::Map::getVersion ( ) const
inlinenoexcept

Get the version of the TMX format.

Returns
the version of the TMX format (generally "1.0")
unsigned tmx::Map::getWidth ( ) const
inlinenoexcept

Get the width of the map.

Returns
the width of the map (in number of tiles)
static std::unique_ptr<Map> tmx::Map::parseFile ( const boost::filesystem::path &  filename)
static

Parse a TMX file.

Parameters
filenamethe name of the TMX file
Returns
a map
void tmx::Map::visitLayers ( LayerVisitor visitor) const
inline

Visit the layers with a visitor.

Parameters
visitorthe visitor