tmxlite
lightweight Tiled tmx map parser for C++
Classes | Public Member Functions | List of all members
tmx::Map Class Referencefinal

Parser for TMX format tile maps. This class can be used to parse the XML format tile maps created with the Tiled map editor, providing an interface to create drawable and physics objects. Typical usage would be to create an instance of this class before calling load() providing a path to the *.tmx file to be loaded. Then layers or objects can be requested from the Map class to be interpreted as needed. More...

#include <Map.hpp>

Public Member Functions

 Map (const Map &)=delete
 
Mapoperator= (const Map &)=delete
 
 Map (Map &&)=default
 
Mapoperator= (Map &&)=default
 
bool load (const std::string &)
 Attempts to parse the tilemap at the given location. More...
 
const VersiongetVersion () const
 Returns the version of the tile map last parsed. If no tile map has yet been parsed the version will read 0, 0.
 
Orientation getOrientation () const
 Returns the orientation of the map if one is loaded, else returns None.
 
RenderOrder getRenderOrder () const
 Returns the RenderOrder of the map if one is loaded, else returns None.
 
const Vector2ugetTileCount () const
 Returns the tile count of the map in the X and Y directions.
 
const Vector2ugetTileSize () const
 Returns the size of the tile grid in this map. Actual tile sizes may vary and will be extended / shrunk about the bottom left corner of the tile.
 
FloatRect getBounds () const
 Returns the bounds of the map.
 
float getHexSideLength () const
 Returns the length of an edge of a tile if a Hexagonal map is loaded. The length returned is in pixels of the straight edge running along the axis returned by getStaggerAxis(). If no map is loaded or the loaded map is not of Hexagonal orientation this function returns 0.f.
 
StaggerAxis getStaggerAxis () const
 Stagger axis of the map. If either a Staggered or Hexagonal tile map is loaded this returns which axis the map is staggered along, else returns None.
 
StaggerIndex getStaggerIndex () const
 Stagger Index of the loaded map. If a Staggered or Hexagonal map is loaded this returns whether the even or odd rows of tiles are staggered, otherwise it returns None.
 
const ColourgetBackgroundColour () const
 Returns the background colour of the map.
 
const std::vector< Tileset > & getTilesets () const
 Returns a reference to the vector of tile sets used by the map.
 
const std::vector< Layer::Ptr > & getLayers () const
 Returns a reference to the vector containing the layer data. Layers are pointer-to-baseclass, the concrete type of which can be found via Layer::getType() More...
 
const std::vector< Property > & getProperties () const
 Returns a vector of Property objects loaded by the map.
 

Detailed Description

Parser for TMX format tile maps. This class can be used to parse the XML format tile maps created with the Tiled map editor, providing an interface to create drawable and physics objects. Typical usage would be to create an instance of this class before calling load() providing a path to the *.tmx file to be loaded. Then layers or objects can be requested from the Map class to be interpreted as needed.

Member Function Documentation

§ getLayers()

const std::vector<Layer::Ptr>& tmx::Map::getLayers ( ) const
inline

Returns a reference to the vector containing the layer data. Layers are pointer-to-baseclass, the concrete type of which can be found via Layer::getType()

See also
Layer

§ load()

bool tmx::Map::load ( const std::string &  )

Attempts to parse the tilemap at the given location.

Parameters
std::stringPath to map file to try to parse
Returns
true if map was parsed successfully else returns false. In debug mode this will attempt to log any errors to the console.

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