me.TMXTileMap(levelId, data)

new TMXTileMap(levelId, data)

a TMX Tile Map Object Tiled QT +0.7.x format

Parameters:
Name Type Description
levelId String

name of TMX map

data Object

TMX map in JSON format

Example
// create a new level object based on the TMX JSON object
var level = new me.TMXTileMap(levelId, me.loader.getTMX(levelId));
// add the level to the game world container
level.addTo(me.game.world, true);

Extends

Members

cols :Number

width of the tilemap in tiles

infinite :Number

is the map an infinite map

Default Value:
  • 0

name :String

name of the tilemap

orientation :String

the map orientation type. melonJS supports “orthogonal”, “isometric”, “staggered” and “hexagonal”.

Default Value:
  • "orthogonal"

renderorder :String

the order in which tiles on orthogonal tile layers are rendered. (valid values are "left-down", "left-up", "right-down", "right-up")

Default Value:
  • "right-down"

rows :Number

height of the tilemap in tiles

tiledversion :String

The Tiled version used to save the file (since Tiled 1.0.1).

tileheight :Number

Tile height

tilewidth :Number

Tile width

version :String

the TMX format version

Methods

static getRenderer(layeropt) → {me.TMXRenderer}

Return the map default renderer

Parameters:
Name Type Attributes Description
layer me.TMXLayer <optional>

a layer object

Returns:
me.TMXRenderer -

a TMX renderer

addTo(target, flatten)

add all the map layers and objects to the given container

Parameters:
Name Type Description
target me.Container

container

flatten boolean

if true, flatten all objects into the given container

Example
// create a new level object based on the TMX JSON object
var level = new me.TMXTileMap(levelId, me.loader.getTMX(levelId));
// add the level to the game world container
level.addTo(me.game.world, true);

destroy()

destroy function, clean all allocated objects

getLayers() → {Array.<me.TMXLayer>}

return all the existing layers

Returns:
Array.<me.TMXLayer> -

Array of Layers

getObjects(flatten) → {Array.<me.Renderable>}

return an Array of instantiated objects, based on the map object definition

Parameters:
Name Type Description
flatten boolean

if true, flatten all objects into the returned array,
ignoring all defined groups (no sub containers will be created)

Returns:
Array.<me.Renderable> -

Array of Objects