Tools

format.tmx.Tools (Class)

... @author Yanrishatum

Static Members

applyTSX(tsx: TmxTileset, base: TmxTileset): Void
Name Type
tsx TmxTileset
base TmxTileset

applyObjectTypeTemplate(obj: TmxObject, ot: TmxObjectTypeTemplate): Void
Name Type
obj TmxObject
ot TmxObjectTypeTemplate

resolveOTExternalTile(map: TmxMap, ?mapPath: String): Void

Resolves OTExternalTile into OTTile. Only works if templates and tilesets were resolved and their paths are relative.

Name Type Default Description
map TmxMap
mapPath String (optional) Optional local path to the map file used for accurate TSX path resolving when comparing tilesets.

linearLayers(map: TmxMap): Array<Anonymous>

Returns linear array of layers removing all nested groups. IMPORTANT! This function will apply group offset/opacity/visibility values to nested layers, don't use it if you need to keep them unchanged.

Name Type
map TmxMap
Returns
Array

propagateObjectTypeToObject(obj: TmxObject, types: Map): Void

Propagates properties from Object Type Template for specific object

Name Type Description
obj TmxObject @param types
types Map

propagateTilePropertiesToObject(obj: TmxObject, map: TmxMap, gid: Int): Void

Propagates tile properties of tile object in tileset to specific object.

Name Type Description
obj TmxObject Object to propagate tile data to.
map TmxMap @param gid Global tile ID from which to take properties.
gid Int Global tile ID from which to take properties.

propagateTileProperties(map: TmxMap): Void
Name Type
map TmxMap

propagateObjectTypes(map: TmxMap, types: Map, ?propagateObjectLayers: Bool = true, ?propagateTileColliders: Bool = true): Void

Propagates properties from Object Type templates to all objects on the map.

Name Type Default Description
map TmxMap Map to which properties should propagate.
types Map List of Object Type Templates by names.
propagateObjectLayers Bool true Should propagate to objects on ObjectLayers?
propagateTileColliders Bool true Should propagate to objects in collisions of tile objects?

getTileByGid(map: TmxMap, gid: Int): TmxTilesetTile

Returns Tile settings for given tile global ID.

Name Type
map TmxMap
gid Int
Returns
TmxTilesetTile

getTilesetByGid(map: TmxMap, gid: Int): TmxTileset

Returns tileset in which given global ID present.

Name Type
map TmxMap
gid Int
Returns
TmxTileset

getTilesetIndexByGid(map: TmxMap, gid: Int): Int

Returns tileset index in which given global ID present.

Name Type
map TmxMap
gid Int
Returns
Int

getTileUVByLidUnsafe(tileset: TmxTileset, localId: Int, output: Dynamic): Void

Sets x and y values to output relative to tile position on source image of tileset. Note: Currently do not supports non-zero margin and spacing values.

Name Type Description
tileset TmxTileset *
localId Int *
output Dynamic

fixObjectPlacement(map: TmxMap): Void

Shifts origin of objects from bottom-left edge to top-left edge. Left out for compatibility

Name Type
map TmxMap

topLeftObjectOrigin(map: TmxMap): Void

Shifts origin of objects from bottom-left edge to top-left edge.

Name Type
map TmxMap

getTilesCountInLineOnTileset(tileset: TmxTileset): Int

Returns amount of tiles in one line in given tileset. Use it for UV calculation.

Name Type
tileset TmxTileset
Returns
Int

getTilesCountInColumnOnTileset(tileset: TmxTileset): Int

Returns amount of tiles in one column in given tileset. UV calculation.

Name Type
tileset TmxTileset
Returns
Int

getTilesCountInTileset(tileset: TmxTileset): Int

Returns total amount of tiles in tileset.

Name Type
tileset TmxTileset
Returns
Int

tilePosition(map: TmxMap, tx: Int, ty: Int, ?tileset: TmxTileset, ?lid: Int): AnonStruct

Returns visual tile position based on the map parameters and optionally on tileset sizes.

Name Type Default Description
map TmxMap
tx Int
ty Int
tileset TmxTileset (optional) Optional tileset reference. If present, it's tile sizes will be used for position calculation.
lid Int (optional) Optional local tile ID on tileset. Required for imageset tilesets.
Returns
AnonStruct

Private Members

resolveOTExternalTileInternal(map: TmxMap, layer: Anonymous, mapPath: String, paths: Array<String>): Void
Name Type
map TmxMap
layer Anonymous
mapPath String
paths Array<String>

linearLayersInternal(group: TmxGroup, output: Array<Anonymous>): Void
Name Type
group TmxGroup
output Array

propagateTilePropertiesLayer(map: TmxMap, layer: Anonymous): Void
Name Type
map TmxMap
layer Anonymous