tiled

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 11 Imported by: 3

Documentation

Index

Constants

View Source
const (
	FlipHorizontalFlag uint32 = 0x80000000
	FlipVerticalFlag   uint32 = 0x40000000
	FlipDiagonalFlag   uint32 = 0x20000000
	RotateHexFlag      uint32 = 0x10000000
	GIDMask            uint32 = 0x1FFFFFFF
)

Variables

This section is empty.

Functions

func DecodeContent

func DecodeContent(content string, encoding Encoding, compression Compression) ([]uint32, error)

func ObjectAlignmentAnchor added in v0.1.4

func ObjectAlignmentAnchor(alignment ObjectAlignment) (ax, ay float32)

Types

type Chunk

type Chunk struct {
	X      int32    `xml:"x,attr"`
	Y      int32    `xml:"y,attr"`
	Width  int32    `xml:"width,attr"`
	Height int32    `xml:"height,attr"`
	Tiles  []uint32 `xml:"-"`

	Content string `xml:",chardata"`
}

type Compression

type Compression uint8
const (
	CompressionNone Compression = iota
	CompressionGzip
	CompressionZlib
	CompressionZstd
)

func (Compression) IsValid

func (c Compression) IsValid() bool

func (Compression) String

func (c Compression) String() string

type Data

type Data struct {
	Encoding    Encoding    `xml:"-"`
	Compression Compression `xml:"-"`

	Chunks []Chunk `xml:"chunk,omitempty"`

	Content string `xml:",chardata"`
}

func (*Data) UnmarshalXML

func (dt *Data) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type DrawOrder

type DrawOrder uint8
const (
	DrawOrderIndex DrawOrder = iota
)

func (DrawOrder) IsValid

func (do DrawOrder) IsValid() bool

func (DrawOrder) String

func (do DrawOrder) String() string

type Encoding

type Encoding uint8
const (
	EncodingCSV Encoding = iota
	EncodingBase64
)

func (Encoding) IsValid

func (e Encoding) IsValid() bool

func (Encoding) String

func (e Encoding) String() string

type FlipFlag

type FlipFlag uint8
const (
	FlipHorizontal FlipFlag = 1 << iota
	FlipVertical
	FlipDiagonal
	FlipHex
)

func DecodeGID

func DecodeGID(gid uint32) (tileID uint32, flags FlipFlag)

func (FlipFlag) Diagonal

func (ff FlipFlag) Diagonal() bool

func (FlipFlag) Hex

func (ff FlipFlag) Hex() bool

func (FlipFlag) Horizontal

func (ff FlipFlag) Horizontal() bool

func (FlipFlag) IsValid

func (ff FlipFlag) IsValid() bool

func (FlipFlag) String

func (ff FlipFlag) String() string

func (FlipFlag) Vertical

func (ff FlipFlag) Vertical() bool

type Image

type Image struct {
	Width  int32 `xml:"width,attr,omitempty"`
	Height int32 `xml:"height,attr,omitempty"`

	Source string `xml:"source,attr,omitempty"`
}

type Layer

type Layer struct {
	Width  int32 `xml:"width,attr"`
	Height int32 `xml:"height,attr"`

	Flags LayerFlag `xml:"-"`

	Data Data `xml:"data,omitempty"`

	ID   int32  `xml:"id,attr"`
	Name string `xml:"name,attr"`

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

func LayerByName

func LayerByName(tmx *Tmx, name string) *Layer

func (*Layer) IsLocked

func (l *Layer) IsLocked() bool

func (*Layer) IsVisible

func (l *Layer) IsVisible() bool

func (*Layer) UnmarshalXML

func (l *Layer) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type LayerFlag

type LayerFlag uint8
const (
	LayerFlagLocked LayerFlag = 1 << iota
	LayerFlagVisible
)

func (LayerFlag) IsValid

func (lf LayerFlag) IsValid() bool

func (LayerFlag) String

func (lf LayerFlag) String() string

type MapFlag

type MapFlag uint8
const (
	MapFlagInfinite MapFlag = 1 << iota
)

func (MapFlag) IsValid

func (f MapFlag) IsValid() bool

func (MapFlag) String

func (f MapFlag) String() string

type Object

type Object struct {
	X        float32 `xml:"x,attr"`
	Y        float32 `xml:"y,attr"`
	Width    float32 `xml:"width,attr,omitempty"`
	Height   float32 `xml:"height,attr,omitempty"`
	Rotation float32 `xml:"rotation,attr,omitempty"`

	Flags ObjectFlag `xml:"-"`

	ID       int32  `xml:"id,attr"`
	GID      uint32 `xml:"gid,attr,omitempty"`
	Name     string `xml:"name,attr,omitempty"`
	Template string `xml:"template,attr,omitempty"`

	Polyline Polygon `xml:"polyline,omitempty"`
	Polygon  Polygon `xml:"polygon,omitempty"`

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

func (*Object) IsTemplate

func (o *Object) IsTemplate() bool

func (*Object) IsVisible

func (o *Object) IsVisible() bool

func (*Object) UnmarshalXML

func (o *Object) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type ObjectAlignment

type ObjectAlignment uint8
const (
	ObjectAlignmentUnspecified ObjectAlignment = iota
	ObjectAlignmentTopLeft
	ObjectAlignmentTop
	ObjectAlignmentTopRight
	ObjectAlignmentLeft
	ObjectAlignmentCenter
	ObjectAlignmentRight
	ObjectAlignmentBottomLeft
	ObjectAlignmentBottom
	ObjectAlignmentBottomRight
)

func (ObjectAlignment) IsValid

func (oa ObjectAlignment) IsValid() bool

func (ObjectAlignment) String

func (oa ObjectAlignment) String() string

type ObjectFlag

type ObjectFlag uint8
const (
	ObjectFlagVisible ObjectFlag = 1 << iota
	ObjectFlagTemplate
)

func (ObjectFlag) IsValid

func (of ObjectFlag) IsValid() bool

func (ObjectFlag) String

func (of ObjectFlag) String() string

type ObjectGroup

type ObjectGroup struct {
	Flags     LayerFlag `xml:"-"`
	DrawOrder DrawOrder `xml:"-"`

	ID   int32  `xml:"id,attr"`
	Name string `xml:"name,attr"`

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

func ObjectGroupByName

func ObjectGroupByName(tmx *Tmx, name string) *ObjectGroup

func (*ObjectGroup) UnmarshalXML

func (og *ObjectGroup) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Offset

type Offset struct {
	X int32 `xml:"x,attr,omitempty"`
	Y int32 `xml:"y,attr,omitempty"`
}

type Orientation

type Orientation uint8
const (
	OrientationOrthogonal Orientation = iota
	OrientationIsometric
	OrientationStaggered
	OrientationHexagonal
)

func (Orientation) IsValid

func (o Orientation) IsValid() bool

func (Orientation) String

func (o Orientation) String() string

type Polygon added in v0.1.4

type Polygon struct {
	Points []float32 `xml:"-"` // Flat list of x,y pairs where x=Points[n], y=Points[n+1]
}

func (*Polygon) GetVertex added in v0.1.4

func (p *Polygon) GetVertex(i int) (x, y float32)

func (*Polygon) IsEmpty added in v0.1.4

func (p *Polygon) IsEmpty() bool

func (*Polygon) UnmarshalXML added in v0.1.4

func (p *Polygon) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*Polygon) VertexCount added in v0.1.4

func (p *Polygon) VertexCount() int

type Property

type Property struct {
	Value        string `xml:"value,attr"`
	PropertyType string `xml:"propertytype,attr,omitempty"`

	Name string `xml:"name,attr"`

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

func PropertyByName

func PropertyByName(props []Property, name string) *Property

func PropertyByType

func PropertyByType(props []Property, propertyType string) *Property

type RenderOrder

type RenderOrder uint8
const (
	RenderOrderRightDown RenderOrder = iota
	RenderOrderRightUp
	RenderOrderLeftDown
	RenderOrderLeftUp
)

func (RenderOrder) IsValid

func (ro RenderOrder) IsValid() bool

func (RenderOrder) String

func (ro RenderOrder) String() string

type Tileset

type Tileset struct {
	FirstGID uint32 `xml:"firstgid,attr,omitempty"`
	Source   string `xml:"source,attr,omitempty"`
}

func TilesetByGID

func TilesetByGID(tmx *Tmx, gid uint32) (*Tileset, uint32, int)

type Tmx

type Tmx struct {
	Width      int32 `xml:"width,attr"`
	Height     int32 `xml:"height,attr"`
	TileHeight int32 `xml:"tileheight,attr"`
	TileWidth  int32 `xml:"tilewidth,attr"`

	Flags       MapFlag     `xml:"-"`
	Orientation Orientation `xml:"-"`
	RenderOrder RenderOrder `xml:"-"`

	NextLayerID  int32 `xml:"nextlayerid,attr"`
	NextObjectID int32 `xml:"nextobjectid,attr"`

	Tilesets     []Tileset     `xml:"tileset,omitempty"`
	Layers       []Layer       `xml:"layer,omitempty"`
	ObjectGroups []ObjectGroup `xml:"objectgroup,omitempty"`

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

func (*Tmx) IsInfinite

func (t *Tmx) IsInfinite() bool

func (*Tmx) UnmarshalXML

func (t *Tmx) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Tsx

type Tsx struct {
	TileWidth  int32 `xml:"tilewidth,attr"`
	TileHeight int32 `xml:"tileheight,attr"`
	TileCount  int32 `xml:"tilecount,attr"`
	Columns    int32 `xml:"columns,attr"`

	Image      Image  `xml:"image,omitempty"`
	TileOffset Offset `xml:"tileoffset,omitempty"`

	ObjectAlignment ObjectAlignment `xml:"-"`

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

func (*Tsx) UnmarshalXML

func (t *Tsx) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Tx

type Tx struct {
	Tileset Tileset `xml:"tileset,omitempty"`
	Objects Object  `xml:"object,omitempty"`
}

Directories

Path Synopsis
examples module
shared module

Jump to

Keyboard shortcuts

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