Class: TMXTileMap

me. TMXTileMap

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
Source:
TMXTiledMap.js, line 123
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
Type:
  • Number
Source:
TMXTiledMap.js, line 141

infinite :Number

is the map an infinite map
Type:
  • Number
Default Value:
  • 0
Source:
TMXTiledMap.js, line 172

name :String

name of the tilemap
Type:
  • String
Source:
TMXTiledMap.js, line 133

orientation :String

the map orientation type. melonJS supports “orthogonal”, “isometric”, “staggered” and “hexagonal”.
Type:
  • String
Default Value:
  • "orthogonal"
Source:
TMXTiledMap.js, line 181

renderorder :String

the order in which tiles on orthogonal tile layers are rendered. (valid values are "left-down", "left-up", "right-down", "right-up")
Type:
  • String
Default Value:
  • "right-down"
Source:
TMXTiledMap.js, line 190

rows :Number

height of the tilemap in tiles
Type:
  • Number
Source:
TMXTiledMap.js, line 148

tiledversion :String

The Tiled version used to save the file (since Tiled 1.0.1).
Type:
  • String
Source:
TMXTiledMap.js, line 208

tileheight :Number

Tile height
Type:
  • Number
Source:
TMXTiledMap.js, line 164

tilewidth :Number

Tile width
Type:
  • Number
Source:
TMXTiledMap.js, line 156

version :String

the TMX format version
Type:
  • String
Source:
TMXTiledMap.js, line 200

Methods

<static> getRenderer(layer) → {me.TMXRenderer}

Return the map default renderer
Parameters:
Name Type Argument Description
layer me.TMXLayer <optional>
a layer object
Source:
TMXTiledMap.js, line 263
Returns:
a TMX renderer
Type
me.TMXRenderer

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
Source:
TMXTiledMap.js, line 369
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
Source:
TMXTiledMap.js, line 561

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

return all the existing layers
Source:
TMXTiledMap.js, line 548
Returns:
Array of Layers
Type
Array.<me.TMXLayer>

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)
Source:
TMXTiledMap.js, line 408
Returns:
Array of Objects
Type
Array.<me.Renderable>