Module gamejs/tmx

This is a loader for the general purpose tile map editor "Tiled".

This module can load all ".tmx" files even if additionally base64 encoded (can be configured in Tiled).

This module loads the whole map definition, including the TileSets with all necessary images. For an example on how to render a map loaded with this module, see examples/tiledmap.

You will typically create a Map instance with Map(url) and deal with the layers, tilesets, etc. through the Map instance instead of loading & creating them yourself.

Only orthogonol maps are supported (no isometric maps).

See

http://www.mapeditor.org/
https://github.com/bjorn/tiled/wiki/TMX-Map-Format

Class Map

Instance Properties

Class Tile

Instance Properties

Class TileSets

Instance Methods


Map (url)

A Tiled Map holds all layers defined in the tmx file as well as the necessary tiles to render the map.

Parameters

String url Relative or absolute URL to the tmx file

Map.prototype.height

Height of the map in tiles


Map.prototype.layers


Map.prototype.properties

Custom properties of the map


Map.prototype.tileHeight

Height of a single tile in pixels


Map.prototype.tileWidth

Width of a single tile in pixels


Map.prototype.tiles

All tiles of this map.


Map.prototype.width

Width of the map in tiles


Tile ()

A Tile. Can not be instantiated. Get a Tile by calling getTile(gid) on a TileSets instance.


Tile.prototype.properties


Tile.prototype.surface


TileSets (mapNode, mapUrl)

A TileSets instance holds all tilesets of a map. This class makes it easy to get the image for a certain tile ID. You usually don't care about in which specific TileSet an image is so this class holds them all and deals with the lookup.

You don't usually create a TileSets instance yourself, instead it is automatically created and attached to a Map.

Parameters

mapNode
mapUrl

TileSets.prototype.getProperties (gid)

Parameters

Number gid global tile id

Returns

Object the custom properties of this tile

TileSets.prototype.getSurface (gid)

Retrieve the image for a tile ID (gid).

Parameters

Number gid global tile id to retrieve

Returns

gamejs.Surface the Surface for the gid

TileSets.prototype.getTile (gid)

Parameters

Number gid global tile id

Returns

Object the Tile object for this gid