Class: TMXLayer

me. TMXLayer

new TMXLayer(data, tilewidth, tileheight, orientation, tilesets, z)

a TMX Tile Layer Object Tiled QT 0.7.x format
Parameters:
Name Type Description
data Object layer data in JSON format (http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer)
tilewidth Number width of each tile in pixels
tileheight Number height of each tile in pixels
orientation String "isometric" or "orthogonal"
tilesets me.TMXTilesetGroup tileset as defined in Tiled
z Number z-index position
Source:
TMXLayer.js, line 60

Extends

Members

alpha :Number

Define the renderable opacity
Set to zero if you do not wish an object to be drawn
Type:
  • Number
Inherited From:
Default Value:
  • 1.0
Source:
renderable.js, line 209
See:
  • me.Renderable#setOpacity
  • me.Renderable#getOpacity

ancestor :me.Container|me.Entity

a reference to the parent object that contains this renderable, or undefined if it has not been added to one.
Type:
Inherited From:
Default Value:
  • undefined
Source:
renderable.js, line 221

isAnimated :Boolean

Layer contains tileset animations
Type:
  • Boolean
Source:
TMXLayer.js, line 106

tilesets :me.TMXTilesetGroup

The Layer corresponding Tilesets
Type:
Source:
TMXLayer.js, line 75

Methods

<static> clearTile(x, y)

clear the tile at the specified position
Parameters:
Name Type Description
x Number X coordinate (in map coordinates: row/column)
y Number Y coordinate (in map coordinates: row/column)
Source:
TMXLayer.js, line 297
Example
me.game.world.getChildByType(me.TMXLayer).forEach(function(layer) {
    // clear all tiles at the given x,y coordinates
    layer.clearTile(x, y);
});

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

Return the layer current renderer object
Source:
TMXLayer.js, line 217
Returns:
renderer
Type
me.TMXRenderer

<static> getTile(x, y) → {me.Tile}

Return the Tile object at the specified position
Parameters:
Name Type Description
x Number X coordinate (in world/pixels coordinates)
y Number Y coordinate (in world/pixels coordinates)
Source:
TMXLayer.js, line 245
Returns:
corresponding tile or null if outside of the map area
Type
me.Tile
Example
// get the TMX Map Layer called "Front layer"
var layer = me.game.world.getChildByName("Front Layer")[0];
// get the tile object corresponding to the latest pointer position
var tile = layer.getTile(me.input.pointer.pos.x, me.input.pointer.pos.y);

<static> getTileId(x, y) → {Number}

Return the TileId of the Tile at the specified position
Parameters:
Name Type Description
x Number X coordinate (in world/pixels coordinates)
y Number Y coordinate (in world/pixels coordinates)
Source:
TMXLayer.js, line 230
Returns:
TileId or null if there is no Tile at the given position
Type
Number

<static> setRenderer(renderer)

Se the TMX renderer for this layer object
Parameters:
Name Type Description
renderer me.TMXRenderer
Source:
TMXLayer.js, line 205

<static> setTile(x, y, tileId) → {me.Tile}

Create a new Tile at the specified position
Parameters:
Name Type Description
x Number X coordinate (in map coordinates: row/column)
y Number Y coordinate (in map coordinates: row/column)
tileId Number tileId
Source:
TMXLayer.js, line 273
Returns:
the corresponding newly created tile object
Type
me.Tile