tmxlite: tmx::Tileset Class Reference

tmxlite 1.0.0 lightweight parse for Tiled maps

Classes | Public Types | 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 | 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...
struct | Terrain
| Terrain information with which one or more tiles may be associated. More...

## Public Types
enum class | ObjectAlignment { Unspecified , TopLeft , Top , TopRight , Left , Center , Right , BottomLeft , Bottom , BottomRight }
| Declares the alignment of tile Objects.

## Public Member Functions
| Tileset (const std::string &workingDir="")
bool | loadWithoutMap (const std::string &path)
| Loads the tilemap from the given location. This does not set the first GID. This does not support templates. Usually tilemaps are loaded automatically as part of a Map instead.
bool | loadWithoutMapFromString (const std::string &xmlStr)
| Loads the tilemap from the given XML string. This does not set the first GID. This does not support templates. Usually tilemaps are loaded automatically as part of a Map instead.
bool | parse (pugi::xml_node, Map *)
| Attempts to parse the given xml node as part of a map. 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.
void | setFirstGID (std::uint32_t firstGID)
| Sets the first GID of this tile set. This is set automatically if the tileset is loaded as part of a Map.
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 std::string & | getClass () const
| Returns the class of the Tileset, as defined in the editor Tiled 1.9+.
const Vector2u & | getTileSize () 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.
ObjectAlignment | getObjectAlignment () const
| Returns the alignment of tile objects. The default value is ObjectAlignment::Unspecified for compatibility. When the alignment is Unspecified tile objects use BottomLeft in orthogonal mode and Bottom in isometric mode.
const Vector2u & | getTileOffset () 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 Vector2u & | getImageSize () const
| Returns the size of the tile set image in pixels.
const Colour & | getTransparencyColour () 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.
const Tile * | 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(id)

## Detailed Description

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

## Member Function Documentation

## ◆ getObjectAlignment()

ObjectAlignment tmx::Tileset::getObjectAlignment | ( |  | ) | const
| inline

Returns the alignment of tile objects. The default value is ObjectAlignment::Unspecified for compatibility. When the alignment is Unspecified tile objects use BottomLeft in orthogonal mode and Bottom in isometric mode.

See also
  ObjectAlignment

## ◆ 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(id)

Parameters

  id | Tile 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

  id | Tile ID

Returns

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

- D:/W/B/src/tmxlite-1.4.5/tmxlite/include/tmxlite/Tileset.hpp