libtmx  0.4.0
an C++11 library for reading TMX files
libtmx Documentation

libtmx is a C++11 library for reading TMX files. TMX (Tile Map XML) is a XML dialect used in Tiled, a tile map editor. libtmx is not meant to modify TMX files but to read TMX files. Its main use case is for games that use TMX maps. The library is not a rendering library, so it does not depend on any graphical toolkit.

Basic usage

First, you have to parse a map file.

std::unique_ptr<tmx::Map> map = tmx::Map::parseFile(path);

Then, you can navigate through the map with the methods of tmx::Map or you can define a class that visits every layer thanks to the visitor pattern.

class MyVisitor : public tmx::LayerVisitor {
virtual void visitTileLayer(const tmx::Map& map, const tmx::TileLayer& layer) override {
// do something with this layer
}
virtual void visitObjectLayer(const tmx::Map& map, const tmx::ObjectLayer& layer) override {
// do something with this layer
}
virtual void visitImageLayer(const tmx::Map& map, const tmx::ImageLayer& layer) override {
// do something with this layer
}
}

And then, give the visitor to the map.

MyVisitor visitor;
map->visitLayers(visitor);

For more information, see:

License

This library is open source and is distributed under the ISC license.