A C++17 library to parse maps generated by
Tiled Map Editor.
Fully supports TMX Map Format version 1.5
.
- Conformity with the TMX specification page.
- (Currently supports TMX Map Format
version 1.5
. Earlier versions are not officially supported.)
- (Currently supports TMX Map Format
The library requires C++17 to build, including compiler and standard library support.
Library | Version |
---|---|
TinyXML2 | 9.0.0 |
zlib | 1.2.13 |
zstd | 1.5.2 |
This describes the installation process using cmake. As pre-requisites, you'll need git and cmake installed.
# Check out the library.
$ git clone https://github.com/KaseyJenkins/tinytmx.git
# Go to the library root directory
$ cd tinytmx
# Make a build directory to place the build output.
$ cmake -E make_directory "build"
# Generate build system files with cmake.
$ cmake -E chdir "build" cmake -DCMAKE_BUILD_TYPE=Release ../
# or, starting with CMake 3.13, use a simpler form:
# cmake -DCMAKE_BUILD_TYPE=Release -S . -B "build"
# Build the library.
$ cmake --build "build" --config Release
If you want to install the library globally, run:
sudo cmake --build "build" --config Release --target install
Parsing a Tiled TMX Map:
#include <string>
#include "tinytmx.hpp"
int main(int argc, char * argv[]) {
tinytmx::Map *map = new tinytmx::Map();
std::string fileName = "assets/FiniteOrthogonalMap.tmx";
map->ParseFile(fileName);
}
If using CMake, it is recommended to link against the project-provided
tinytmx::tinytmx
target using target_link_libraries
.
It is possible to use find_package
to import an installed version of the library.
find_package(tinytmx REQUIRED)
Alternatively,
add_subdirectory
will incorporate the library directly
into one's CMake project.
add_subdirectory(tinytmx)
Either way, link to the library as follows.
target_link_libraries(MyTarget tinytmx::tinytmx)