Documentation
¶
Index ¶
- Constants
- func Draw(ctx finch.Context, img *ebiten.Image, tmx *TMX)
- func DrawLayer(ctx finch.Context, img *ebiten.Image, tmx *TMX, layerName string)
- func DrawLayerRegion(ctx finch.Context, img *ebiten.Image, tmx *TMX, layerName string, ...)
- func DrawObject(ctx finch.Context, img *ebiten.Image, tmx *TMX, obj *Object, ...)
- func DrawRegion(ctx finch.Context, img *ebiten.Image, tmx *TMX, region geom.Rect64)
- func DrawScene(ctx finch.Context, img *ebiten.Image, tmx *TMX, viewport geom.Rect64, ...)
- func DrawSceneLayer(ctx finch.Context, img *ebiten.Image, tmx *TMX, layerName string, ...)
- func GetTSXImg(file finch.AssetFile) (*ebiten.Image, error)
- func GetTXImg(file finch.AssetFile) (*ebiten.Image, error)
- func MustGetTSXImg(file finch.AssetFile) *ebiten.Image
- func MustGetTXImg(file finch.AssetFile) *ebiten.Image
- func RegisterTiledAssetImporters()
- type AttrBool
- type AttrInt
- type AttrString
- type DataChunk
- type DrawMode
- type Encoding
- type FlipFlags
- type Image
- type Layer
- type LayerData
- type LayerPartitions
- type Object
- func (obj Object) GID() int
- func (obj Object) HasTemplate() bool
- func (obj Object) Height() int
- func (obj Object) ID() int
- func (obj Object) Name() string
- func (obj Object) PropertyOfType(ptype string) (*Property, bool)
- func (obj Object) Template() string
- func (obj Object) Width() int
- func (obj Object) X() int
- func (obj Object) Y() int
- type ObjectAlignment
- type ObjectGroup
- type Offset
- type Orientation
- type Property
- type RenderOrder
- type TMX
- func (tmx TMX) Bounds() geom.Rect64
- func (tmx TMX) Height() int
- func (tmx TMX) IsInfinite() bool
- func (tmx TMX) LayerByName(name string) *Layer
- func (tmx TMX) LayerByProperty(ptype string, pvalue any) *Layer
- func (tmx TMX) ObjectGroupByName(name string) *ObjectGroup
- func (tmx TMX) ObjectGroupByProperty(ptype string, pvalue any) *ObjectGroup
- func (tmx TMX) Orientation() Orientation
- func (tmx TMX) RenderOrder() RenderOrder
- func (tmx TMX) TileHeight() int
- func (tmx TMX) TileWidth() int
- func (tmx TMX) TiledVersion() string
- func (tmx TMX) Version() string
- func (tmx TMX) Width() int
- type TSX
- func (tsx TSX) Columns() int
- func (tsx TSX) Name() string
- func (tsx TSX) ObjectAlignment() geom.Point64
- func (tsx TSX) Spacing() int
- func (tsx TSX) TileCount() int
- func (tsx TSX) TileHeight() int
- func (tsx TSX) TileOffsetX() int
- func (tsx TSX) TileOffsetY() int
- func (tsx TSX) TileWidth() int
- func (tsx TSX) TiledVersion() string
- func (tsx TSX) Version() string
- type TX
- type Tile
- type TiledObjectFactory
- type TiledXMLAttr
- type TiledXMLAttrTable
- type Tileset
Constants ¶
const ( TMXAssetType = "tmx" TSXAssetType = "tsx" TXAssetType = "tx" )
const ( TILE_FLIP_HORIZONTAL = 0x80000000 TILE_FLIP_VERTICAL = 0x40000000 TILE_FLIP_DIAGONAL = 0x20000000 TILE_FLIP_ROTATED_HEX = 0x10000000 TILE_ID_MASK = 0x1FFFFFFF )
const ( ColumnsAttr = "columns" EncodingAttr = "encoding" FirstGIDAttr = "firstgid" GIDAttr = "gid" HeightAttr = "height" IDAttr = "id" InfiniteAttr = "infinite" LockedAttr = "locked" NameAttr = "name" NextLayerIDAttr = "nextlayerid" NextObjectIDAttr = "nextobjectid" ObjectAlignmentAttr = "objectalignment" OrientationAttr = "orientation" PropertyTypeAttr = "propertytype" RenderOrderAttr = "renderorder" SourceAttr = "source" SpacingAttr = "spacing" TemplateAttr = "template" TileCountAttr = "tilecount" TileHeightAttr = "tileheight" TileWidthAttr = "tilewidth" TiledVersionAttr = "tiledversion" ValueAttr = "value" VersionAttr = "version" VisibleAttr = "visible" WidthAttr = "width" XAttr = "x" YAttr = "y" )
const (
ErrWhileDrawingLayer = "tiled: error while drawing layer"
)
Variables ¶
This section is empty.
Functions ¶
func Draw ¶
Draw attempts to render the entire TMX map onto the provided image. If the map is larger than the image, only the top-left portion will be drawn.
func DrawLayer ¶ added in v0.0.4
DrawLayer attempts to render a specific layer of the TMX map onto the provided image. If the map is larger than the image, only the top-left portion will be drawn.
func DrawLayerRegion ¶ added in v0.0.4
func DrawLayerRegion(ctx finch.Context, img *ebiten.Image, tmx *TMX, layerName string, region geom.Rect64)
DrawLayerRegion renders only the specified region of a specific layer of the TMX map onto the provided image.
func DrawObject ¶ added in v0.0.9
func DrawObject(ctx finch.Context, img *ebiten.Image, tmx *TMX, obj *Object, transform ebiten.GeoM, view ebiten.GeoM)
DrawObject renders a specific drawable object from the TMX map using the provided view matrix.
func DrawRegion ¶
DrawRegion renders only the specified region of the TMX map onto the provided image.
func DrawScene ¶
func DrawScene(ctx finch.Context, img *ebiten.Image, tmx *TMX, viewport geom.Rect64, viewMatrix ebiten.GeoM)
DrawScene renders the TMX map as seen through a camera, using the provided viewport and view matrix. This is typically used for rendering the map in a game scene where the camera can move and zoom.
func DrawSceneLayer ¶ added in v0.0.4
func DrawSceneLayer(ctx finch.Context, img *ebiten.Image, tmx *TMX, layerName string, viewport geom.Rect64, viewMatrix ebiten.GeoM)
DrawSceneLayer renders a specific layer of the TMX map as seen through a camera, using the provided viewport and view matrix. This is typically used for rendering the map in a game scene where the camera can move and zoom.
func GetTXImg ¶ added in v0.0.7
GetTXImg retrieves the image associated with a TX asset.
Images are retrieved from the TSX asset referenced by the TX.
func MustGetTSXImg ¶ added in v0.0.2
MustGetTSXImg is like GetTSXImg but panics if the asset cannot be found.
func MustGetTXImg ¶ added in v0.0.7
MustGetTXImg is like GetTXImg but panics if the asset cannot be found.
func RegisterTiledAssetImporters ¶ added in v0.0.7
func RegisterTiledAssetImporters()
Types ¶
type AttrString ¶
type AttrString string
func UnmarshalAttrString ¶
func UnmarshalAttrString(s string) (AttrString, error)
func (AttrString) String ¶
func (s AttrString) String() string
type DataChunk ¶ added in v0.0.7
type DataChunk struct {
Attrs TiledXMLAttrTable `xml:",any,attr"`
Data string `xml:",chardata"`
}
type Encoding ¶ added in v0.0.7
type Encoding int
func (Encoding) MarshalJSON ¶ added in v0.0.7
func (*Encoding) UnmarshalJSON ¶ added in v0.0.7
type FlipFlags ¶ added in v0.0.7
type FlipFlags uint8
func (FlipFlags) FlipDiagonal ¶ added in v0.0.7
func (FlipFlags) FlipHorizontal ¶ added in v0.0.7
func (FlipFlags) FlipRotatedHex ¶ added in v0.0.7
func (FlipFlags) FlipVertical ¶ added in v0.0.7
type Image ¶ added in v0.0.7
type Image struct {
Attrs TiledXMLAttrTable `xml:",any,attr"`
}
type Layer ¶ added in v0.0.7
type Layer struct {
Attrs TiledXMLAttrTable `xml:",any,attr"`
Data *LayerData `xml:"data"`
Properties []*Property `xml:"properties>property"`
// contains filtered or unexported fields
}
func (Layer) PropertyOfType ¶ added in v0.0.9
type LayerData ¶ added in v0.0.7
type LayerData struct {
Attrs TiledXMLAttrTable `xml:",any,attr"`
Chunks []*DataChunk `xml:"chunk"`
Data string `xml:",chardata"`
}
type LayerPartitions ¶
type Object ¶ added in v0.0.7
type Object struct {
Attrs TiledXMLAttrTable `xml:",any,attr"`
Properties []*Property `xml:"properties>property"`
Tileset *Tileset `xml:"tileset"`
// contains filtered or unexported fields
}
func (Object) HasTemplate ¶ added in v0.0.7
func (Object) PropertyOfType ¶ added in v0.0.7
type ObjectAlignment ¶ added in v0.0.9
type ObjectAlignment int
const ( ObjectAlignmentUnspecified ObjectAlignment = iota ObjectAlignmentTopLeft ObjectAlignmentTop ObjectAlignmentTopRight ObjectAlignmentLeft ObjectAlignmentCenter ObjectAlignmentRight ObjectAlignmentBottomLeft ObjectAlignmentBottom ObjectAlignmentBottomRight )
func (ObjectAlignment) IsValid ¶ added in v0.0.9
func (oa ObjectAlignment) IsValid() bool
func (ObjectAlignment) MarshalJSON ¶ added in v0.0.9
func (oa ObjectAlignment) MarshalJSON() ([]byte, error)
func (ObjectAlignment) String ¶ added in v0.0.9
func (oa ObjectAlignment) String() string
func (*ObjectAlignment) UnmarshalJSON ¶ added in v0.0.9
func (oa *ObjectAlignment) UnmarshalJSON(data []byte) error
type ObjectGroup ¶ added in v0.0.7
type ObjectGroup struct {
Attrs TiledXMLAttrTable `xml:",any,attr"`
Objects []*Object `xml:"object"`
Properties []*Property `xml:"properties>property"`
}
func (ObjectGroup) ID ¶ added in v0.0.7
func (og ObjectGroup) ID() int
func (ObjectGroup) Name ¶ added in v0.0.7
func (og ObjectGroup) Name() string
func (ObjectGroup) PropertyOfType ¶ added in v0.0.9
func (og ObjectGroup) PropertyOfType(ptype string) (*Property, bool)
type Offset ¶ added in v0.0.7
type Offset struct {
Attrs TiledXMLAttrTable `xml:",any,attr"`
}
type Orientation ¶ added in v0.0.7
type Orientation int
const ( Orthogonal Orientation = iota Isometric Staggered Hexagonal )
func (Orientation) IsValid ¶ added in v0.0.7
func (o Orientation) IsValid() bool
func (Orientation) MarshalJSON ¶ added in v0.0.7
func (o Orientation) MarshalJSON() ([]byte, error)
func (Orientation) String ¶ added in v0.0.7
func (o Orientation) String() string
func (*Orientation) UnmarshalJSON ¶ added in v0.0.7
func (o *Orientation) UnmarshalJSON(data []byte) error
type Property ¶ added in v0.0.7
type Property struct {
Attrs TiledXMLAttrTable `xml:",any,attr"`
Properties []*Property `xml:"properties>property"`
}
func (Property) PropertyOfType ¶ added in v0.0.7
func (Property) PropertyType ¶ added in v0.0.7
type RenderOrder ¶ added in v0.0.7
type RenderOrder int
const ( TMXRightDown RenderOrder = iota TMXRightUp TMXLeftDown TMXLeftUp )
func (RenderOrder) IsValid ¶ added in v0.0.7
func (ro RenderOrder) IsValid() bool
func (RenderOrder) MarshalJSON ¶ added in v0.0.7
func (ro RenderOrder) MarshalJSON() ([]byte, error)
func (RenderOrder) String ¶ added in v0.0.7
func (ro RenderOrder) String() string
func (*RenderOrder) UnmarshalJSON ¶ added in v0.0.7
func (ro *RenderOrder) UnmarshalJSON(data []byte) error
type TMX ¶
type TMX struct {
Attrs TiledXMLAttrTable `xml:",any,attr"`
ObjectGroups []*ObjectGroup `xml:"objectgroup"`
Tilesets []*Tileset `xml:"tileset"`
Layers []*Layer `xml:"layer"`
}
TMX represents a deserialized Tiled tmx file.
func MustGetTMX ¶
MustGetTMX is like GetTMX but panics if the asset cannot be found.
func (TMX) IsInfinite ¶
func (TMX) LayerByName ¶ added in v0.0.9
func (TMX) LayerByProperty ¶ added in v0.0.9
func (TMX) ObjectGroupByName ¶ added in v0.0.9
func (tmx TMX) ObjectGroupByName(name string) *ObjectGroup
func (TMX) ObjectGroupByProperty ¶ added in v0.0.9
func (tmx TMX) ObjectGroupByProperty(ptype string, pvalue any) *ObjectGroup
func (TMX) Orientation ¶
func (tmx TMX) Orientation() Orientation
func (TMX) RenderOrder ¶
func (tmx TMX) RenderOrder() RenderOrder
func (TMX) TileHeight ¶
func (TMX) TiledVersion ¶
type TSX ¶
type TSX struct {
Attrs TiledXMLAttrTable `xml:",any,attr"`
TileOffset *Offset `xml:"tileoffset"`
Image *Image `xml:"image"`
}
func MustGetTSX ¶
MustGetTSX is like GetTSX but panics if the asset cannot be found.
func MustGetTXTSX ¶ added in v0.0.7
MustGetTXTSX is like GetTXTSX but panics if the asset cannot be found.
func (TSX) ObjectAlignment ¶ added in v0.0.9
func (TSX) TileHeight ¶
func (TSX) TileOffsetX ¶ added in v0.0.9
func (TSX) TileOffsetY ¶ added in v0.0.9
func (TSX) TiledVersion ¶
type TX ¶ added in v0.0.7
type TX struct {
Attrs TiledXMLAttrTable `xml:",any,attr"`
Tileset *Tileset `xml:"tileset"`
Object *Object `xml:"object"`
}
type TiledObjectFactory ¶ added in v0.0.9
type TiledXMLAttr ¶
type TiledXMLAttr interface {
String() string
}
type TiledXMLAttrTable ¶
type TiledXMLAttrTable map[string]TiledXMLAttr
func (*TiledXMLAttrTable) UnmarshalXMLAttr ¶
func (m *TiledXMLAttrTable) UnmarshalXMLAttr(attr xml.Attr) error