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) → {}
Parameters:
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

Properties inherited from Rect

number
bottom
number
centerX
number
centerY
number
height
number
left
number
right
number
top
string
type = "Rectangle"
number
width

Properties inherited from Polygon

Array<Vector2d>
points

Public Properties


animatedTilesets TMXLayer.js:116
animatedTilesets: Array<TMXTileset>

Array<TMXTileset>

All animated tilesets in this layer

class TMXLayer.js:136
class: string

string

the layer class

isAnimated TMXLayer.js:122
isAnimated: boolean = false

boolean

Layer contains tileset animations

renderorder TMXLayer.js:128
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")

tilesets TMXLayer.js:95
tilesets: TMXTilesetGroup

TMXTilesetGroup

The Layer corresponding Tilesets

x TMXLayer.js:81
x: number = 0

number

Horizontal layer offset in tiles

y TMXLayer.js:88
y: number = 0

number

Vertical layer offset in tiles

Public Methods


cellAt TMXLayer.js:341
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);
Parameters:
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

Returns:
Type Description
Tile

corresponding tile or null if there is no defined tile at the position or if outside of the layer bounds

clearTile TMXLayer.js:364
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);
});
Parameters:
Name Type Description
x number

X coordinate (in map coordinates: row/column)

y number

Y coordinate (in map coordinates: row/column)

getRenderer TMXLayer.js:272
getRenderer() → {TMXRenderer}

Return the layer current renderer object

Returns:
Type Description
TMXRenderer

renderer

getTile TMXLayer.js:291
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);
Parameters:
Name Type Description
x number

X coordinate (in world/pixels coordinates)

y number

Y coordinate (in world/pixels coordinates)

Returns:
Type Description
Tile

corresponding tile or null if there is no defined tile at the coordinate or if outside of the layer bounds

getTileById TMXLayer.js:326
getTileById(tileId: number, x: number, y: number) → {Tile}

return a new the Tile object corresponding to the given tile id

Parameters:
Name Type Description
tileId number

tileId

x number

X coordinate (in world/pixels coordinates)

y number

Y coordinate (in world/pixels coordinates)

Returns:
Type Description
Tile

the tile object

getTileId TMXLayer.js:280
getTileId(x: number, y: number) → {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)

Returns:
Type Description
number

TileId or null if there is no Tile at the given position

setRenderer TMXLayer.js:259
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());
Parameters:
Name Type Description
renderer TMXRenderer
setTile TMXLayer.js:313
setTile(tile: Tile, x: number, y: number) → {Tile}

assign the given Tile object to the specified position

Parameters:
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)

Returns:
Type Description
Tile

the tile object


Powered by webdoc!