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

Represents a Tileset node as loaded from a *.tmx format tile map via the tmx::Map class. More...

#include <Tileset.hpp>

Classes

struct  Terrain
 Terrain information with which one or more tiles may be associated. More...
 
struct  Tile
 Any tiles within a tile set which have special data associated with them such as animation or terrain information will have one of these stored in the tile set. More...
 

Public Member Functions

 Tileset (const std::string &workingDir)
 
void parse (pugi::xml_node)
 Attempts to parse the given xml node. If node parsing fails an error is printed in the console and the Tileset remains in an uninitialised state.
 
std::uint32_t getFirstGID () const
 Returns the first GID of this tile set. This the ID of the first tile in the tile set, so that each tile set guarantees a unique set of IDs.
 
std::uint32_t getLastGID () const
 Returns the last GID of this tile set. This is the ID of the last tile in the tile set.
 
const std::string & getName () const
 Returns the name of this tile set.
 
const Vector2ugetTileSize () const
 Returns the width and height of a tile in the tile set, in pixels.
 
std::uint32_t getSpacing () const
 Returns the spacing, in pixels, between each tile in the set.
 
std::uint32_t getMargin () const
 Returns the margin, in pixels, around each tile in the set.
 
std::uint32_t getTileCount () const
 Returns the number of tiles in the tile set.
 
std::uint32_t getColumnCount () const
 Returns the number of columns which make up the tile set. This is used when rendering collection of images sets.
 
const Vector2ugetTileOffset () const
 Returns the tile offset in pixels. Tile will draw tiles offset from the top left using this value.
 
const std::vector< Property > & getProperties () const
 Returns a reference to the list of Property objects for this tile set.
 
const std::string getImagePath () const
 Returns the file path to the tile set image, relative to the working directory. Use this to load the texture required by whichever method you choose to render the map.
 
const ColourgetTransparencyColour () const
 Returns the colour used by the tile map image to represent transparency. By default this is a transparent colour (0, 0, 0, 0)
 
bool hasTransparency () const
 Returns true if the image used by this tileset specifically requests a colour to use as transparency.
 
const std::vector< Terrain > & getTerrainTypes () const
 Returns a vector of Terrain types associated with one or more tiles within this tile set.
 
const std::vector< Tile > & getTiles () const
 Returns a reference to the vector of tile data used by tiles which make up this tile set.
 
bool hasTile (std::uint32_t id) const
 Checks if a tiled ID is in the range of the first ID and the last ID. More...
 
const TilegetTile (std::uint32_t id) const
 queries tiles and returns a tile with the given ID. More...
 

Detailed Description

Represents a Tileset node as loaded from a *.tmx format tile map via the tmx::Map class.

Member Function Documentation

§ getTile()

const Tile* tmx::Tileset::getTile ( std::uint32_t  id) const

queries tiles and returns a tile with the given ID.

Checks if the TileID is part of the Tileset with hasTile(a_id)

Parameters
idTile ID. The Tile ID will be corrected internally.
Returns
In case of a success it returns the correct tile. In terms of failure it will return a nullptr.

§ hasTile()

bool tmx::Tileset::hasTile ( std::uint32_t  id) const
inline

Checks if a tiled ID is in the range of the first ID and the last ID.

Parameters
idTile ID
Returns

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