tmx

package module
v0.0.0-...-d7f047e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2017 License: MIT Imports: 10 Imported by: 0

README

tmx

A Go package providing a convenient struct for the Tiled editor’s TMX file format.

GoDoc

Build Status

Test Coverage

Documentation

Overview

Package tmx provides a struct for parsing the Tiled map editor's TMX map format. See http://doc.mapeditor.org/reference/tmx-map-format/ .

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	Encoding    string `xml:"encoding,attr"`
	Compression string `xml:"compression,attr"`

	Text  string       `xml:",chardata"`
	Tiles []SingleTile `xml:"tile"`
}

type Ellipse

type Ellipse struct{}

type Image

type Image struct {
	Format string `xml:"format,attr"`
	Source string `xml:"source,attr"`
	Trans  string `xml:"trans,attr"`
	Width  int    `xml:"width,attr"`
	Height int    `xml:"height,attr"`

	Data Data `xml:"data"`
}

type ImageLayer

type ImageLayer struct {
	Name    string  `xml:"name,attr"`
	Opacity float32 `xml:"opacity,attr"`
	Visible bool    `xml:"visible,attr"`

	Properties []Property `xml:"properties>property"`
	Image      Image      `xml:"image"`
}

type Layer

type Layer struct {
	Name    string  `xml:"name,attr"`
	Opacity float32 `xml:"opacity,attr"`
	Visible bool    `xml:"visible,attr"`

	Properties []Property `xml:"properties>property"`
	Data       Data       `xml:"data"`

	// The GID of each tile, in order. Use this instead of raw Data, which is cleaned up by Decode.
	GIDs []int32 `xml:"-"`
}

type Map

type Map struct {
	XMLName         xml.Name `xml:"map"`
	Version         string   `xml:"version,attr"`
	Orientation     string   `xml:"orientation,attr"`
	Width           int      `xml:"width,attr"`
	Height          int      `xml:"height,attr"`
	TileWidth       int      `xml:"tilewidth,attr"`
	TileHeight      int      `xml:"tileheight,attr"`
	BackgroundColor string   `xml:"backgroundcolor,attr"`

	Properties   []Property    `xml:"properties>property"`
	Tilesets     []Tileset     `xml:"tileset"`
	Layers       []Layer       `xml:"layer"`
	ObjectGroups []ObjectGroup `xml:"objectgroup"`
	ImageLayers  []ImageLayer  `xml:"imagelayer"`
}

func Decode

func Decode(r io.Reader) (*Map, error)

type Object

type Object struct {
	Name     string  `xml:"name,attr"`
	Type     string  `xml:"type,attr"`
	X        int     `xml:"x,attr"`
	Y        int     `xml:"y,attr"`
	Width    int     `xml:"width,attr"`
	Height   int     `xml:"height,attr"`
	Rotation float32 `xml:"rotation,attr"`
	GID      int32   `xml:"gid,attr"`
	Visible  bool    `xml:"visible,attr"`

	Properties []Property `xml:"properties>property"`
	Ellipse    *Ellipse   `xml:"ellipse"`
	Polygon    string     `xml:"polygon>points"`
	Polylines  string     `xml:"polyline>points"`
}

type ObjectGroup

type ObjectGroup struct {
	Name    string  `xml:"name,attr"`
	Color   string  `xml:"color,attr"`
	Opacity float32 `xml:"opacity,attr"`
	Visible bool    `xml:"visible,attr"`

	Properties []Property `xml:"properties>property"`
	Objects    []Object   `xml:"object"`
}

type Property

type Property struct {
	Name  string `xml:"name,attr"`
	Value string `xml:"value,attr"`
}

type SingleTile

type SingleTile struct {
	GID int32 `xml:"gid,attr"`
}

type Terrain

type Terrain struct {
	Name string `xml:"name,attr"`
	Tile int    `xml:"tile,attr"`

	Properties []Property `xml:"properties>property"`
}

type Tile

type Tile struct {
	ID          int32   `xml:"id,attr"`
	Terrain     string  `xml:"terrain,attr"`
	Probability float32 `xml:"probability,attr"`

	Properties []Property `xml:"properties>property"`
	Image      Image      `xml:"image"`
}

type TileOffset

type TileOffset struct {
	X int `xml:"x,attr"`
	Y int `xml:"y,attr"`
}

type Tileset

type Tileset struct {
	FirstGID   int32  `xml:"firstgid,attr"`
	Source     string `xml:"source,attr"`
	Name       string `xml:"name,attr"`
	TileWidth  int    `xml:"tilewidth,attr"`
	TileHeight int    `xml:"tileheight,attr"`
	Spacing    int    `xml:"spacing,attr"`
	Margin     int    `xml:"margin,attr"`

	TileOffset   TileOffset `xml:"tileoffset"`
	Properties   []Property `xml:"properties>property"`
	Image        Image      `xml:"image"`
	TerrainTypes []Terrain  `xml:"terraintypes>terrain"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL