TMXLayer
class TMXLayer extends Renderable
a TMX Tile Layer Object Tiled QT 0.7.x format
Constructor
new TMXLayer(map: object, data: object, tilewidth: number, tileheight: number, orientation: string, tilesets: TMXTilesetGroup, z: number) → {}
Name | Type | Description |
---|---|---|
map | object |
layer data in JSON format (http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer) |
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 | TMXTilesetGroup |
tileset as defined in Tiled |
z | number |
z-index position |
Summary
Properties from TMXLayer
Array<TMXTileset> |
|
string |
|
boolean |
|
string |
|
TMXTilesetGroup |
|
number |
|
number |
|
Methods from TMXLayer
Properties inherited from Renderable
number |
|
boolean |
|
Container | Entity |
|
ObservableVector2d |
|
boolean |
|
string |
|
Body |
|
Matrix2d |
|
number |
|
boolean |
|
string |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
Rect | RoundRect | Polygon | Line | Ellipse |
|
string |
|
Function |
|
ObservableVector3d |
|
GLShader |
|
Color |
|
boolean |
|
Properties inherited from Rect
Methods inherited from Renderable
Methods inherited from Rect
Rect |
|
Rect |
|
boolean |
|
Rect |
|
boolean |
|
boolean |
|
boolean |
|
Rect |
|
Rect |
|
Polygon |
|
Rect |
|
Methods inherited from Polygon
Array<number> |
|
boolean |
|
Polygon |
|
Polygon |
|
|
|
Polygon |
|
Polygon |
|
Polygon |
|
Public Properties
animatedTilesets: Array<TMXTileset>
Array<TMXTileset>
All animated tilesets in this layer
renderorder: string = "right-down"
string
the order in which tiles on orthogonal tile layers are rendered. (valid values are "left-down", "left-up", "right-down", "right-up")
Public Methods
cellAt(x: number, y: number, boundsCheck: number) → {Tile}
Return the Tile object at the specified tile coordinates
// return the first tile at offset 0, 0
let tile = layer.cellAt(0, 0);
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number |
x position of the tile (in Tile unit) |
||
y | number |
x position of the tile (in Tile unit) |
||
boundsCheck | number |
<optional> |
true |
check first if within the layer bounds |
Type | Description |
---|---|
Tile |
corresponding tile or null if there is no defined tile at the position or if outside of the layer bounds |
clearTile(x: number, y: number) → {}
clear the tile at the specified position
me.game.world.getChildByType(me.TMXLayer).forEach(function(layer) {
// clear all tiles at the given x,y coordinates
layer.clearTile(x, y);
});
Name | Type | Description |
---|---|---|
x | number |
X coordinate (in map coordinates: row/column) |
y | number |
Y coordinate (in map coordinates: row/column) |
getRenderer() → {TMXRenderer}
Return the layer current renderer object
Type | Description |
---|---|
TMXRenderer |
renderer |
getTile(x: number, y: number) → {Tile}
Return the Tile object at the specified position
// get the TMX Map Layer called "Front layer"
let layer = me.game.world.getChildByName("Front Layer")[0];
// get the tile object corresponding to the latest pointer position
let tile = layer.getTile(me.input.pointer.x, me.input.pointer.y);
Name | Type | Description |
---|---|---|
x | number |
X coordinate (in world/pixels coordinates) |
y | number |
Y coordinate (in world/pixels coordinates) |
Type | Description |
---|---|
Tile |
corresponding tile or null if there is no defined tile at the coordinate or if outside of the layer bounds |
getTileById(tileId: number, x: number, y: number) → {Tile}
return a new the Tile object corresponding to the given tile id
Name | Type | Description |
---|---|---|
tileId | number |
tileId |
x | number |
X coordinate (in world/pixels coordinates) |
y | number |
Y coordinate (in world/pixels coordinates) |
Type | Description |
---|---|
Tile |
the tile object |
getTileId(x: number, y: number) → {number}
Return the TileId of the Tile at the specified position
Name | Type | Description |
---|---|---|
x | number |
X coordinate (in world/pixels coordinates) |
y | number |
Y coordinate (in world/pixels coordinates) |
Type | Description |
---|---|
number |
TileId or null if there is no Tile at the given position |
setRenderer(renderer: TMXRenderer) → {}
Set the TMX renderer for this layer object
// use the parent map default renderer
let layer = new me.TMXLayer(...);
layer.setRenderer(map.getRenderer());
Name | Type | Description |
---|---|---|
renderer | TMXRenderer |
setTile(tile: Tile, x: number, y: number) → {Tile}
assign the given Tile object to the specified position
Name | Type | Description |
---|---|---|
tile | Tile |
the tile object to be assigned |
x | number |
x coordinate (in world/pixels coordinates) |
y | number |
y coordinate (in world/pixels coordinates) |
Type | Description |
---|---|
Tile |
the tile object |