Loading TMX Map Format files created by the Tiled map editor into a Go struct. This package does not do anything fancy, it does not do any decoding, it unmarshalls data from .tmx
and .tsx
files and populates a tmx.Map
struct. It updates tileset and image sources with better path information.
The TMX Map Format documentation was followed as close as possible.
A field used that is not listed in the spec is tmx.Data.InnerXML, it is the raw XML nested inside the tag <data>
.
A field used that is not listed in the spec is tmx.Content, it is used to preserve the order of tmx.Map
and tmx.Group
elements. While building a game engine, the order of each layer in Map and Group became important.
This package only uses standard libraries.
The recommended way to get started using github.com/go-stuff/tiled is by using go get
to install the dependency in your project.
go get github.com/go-stuff/tiled
package main
import (
"fmt"
"log"
"github.com/go-stuff/tiled/tmx"
)
// Test loading and printing a tmx file.
func main() {
t, err := tmx.LoadTMX("./testdata/map.tmx")
if err != nil {
log.Fatal(err)
}
fmt.Println(t.String())
}