TMXTileMap

class TMXTileMap

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

Constructor


new TMXTileMap(levelId: string, data: object) → {}
// create a new level object based on the TMX JSON object
let level = new me.TMXTileMap(levelId, me.loader.getTMX(levelId));
// add the level to the game world container
level.addTo(me.game.world, true);
Parameters:
Name Type Description
levelId string

name of TMX map

data object

TMX map in JSON format

Summary


Properties from TMXTileMap

Methods from TMXTileMap

addTo(container: Container, flatten: boolean, setViewportBounds: boolean)
destroy()

destroy function, clean all allocated objects

Bounds
getBounds()
Array<TMXLayer>
getLayers()
Array<Renderable>
getObjects(flatten: boolean)
TMXRenderer
getRenderer()

Public Properties


class TMXTileMap.js:159
class: string

string

The map class.

cols TMXTileMap.js:101
cols: number = -

number

width of the tilemap in tiles

infinite TMXTileMap.js:125
infinite: number = 0

number

is the map an infinite map

name TMXTileMap.js:95
name: string

string

name of the tilemap

orientation TMXTileMap.js:132
orientation: string = "orthogonal"

string

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

renderorder TMXTileMap.js:139
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")

rows TMXTileMap.js:107
rows: number = -

number

height of the tilemap in tiles

tiledversion TMXTileMap.js:153
tiledversion: string

string

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

tileheight TMXTileMap.js:119
tileheight: number = -

number

Tile height

tilewidth TMXTileMap.js:113
tilewidth: number = -

number

Tile width

version TMXTileMap.js:147
version: string

string

the TMX format version

Public Methods


addTo TMXTileMap.js:304
addTo(container: Container, flatten: boolean, setViewportBounds: boolean) → {}

add all the map layers and objects to the given container. note : this will not automatically update the camera viewport

// create a new level object based on the TMX JSON object
let level = new me.TMXTileMap(levelId, me.loader.getTMX(levelId));
// add the level to the game world container
level.addTo(me.game.world, true, true);
Parameters:
Name Type Attributes Default Description
container Container

target container

flatten boolean

<optional>

true

if true, flatten all objects into the given container, else a me.Container object will be created for each corresponding groups

setViewportBounds boolean

<optional>

false

if true, set the viewport bounds to the map size, this should be set to true especially if adding a level to the game world container.

destroy TMXTileMap.js:559
destroy() → {}

destroy function, clean all allocated objects

getBounds TMXTileMap.js:225
getBounds() → {Bounds}

return the map bounding rect

Returns:
Type Description
Bounds
getLayers TMXTileMap.js:549
getLayers() → {Array<TMXLayer>}

return all the existing layers

Returns:
Type Description
Array<TMXLayer>

Array of Layers

getObjects TMXTileMap.js:379
getObjects(flatten: boolean) → {Array<Renderable>}

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

Parameters:
Name Type Attributes Default Description
flatten boolean

<optional>

true

if true, flatten all objects into the returned array. when false, a me.Container object will be created for each corresponding groups

Returns:
Type Description
Array<Renderable>

Array of Objects

getRenderer TMXTileMap.js:214
getRenderer() → {TMXRenderer}

Return the map default renderer

Returns:
Type Description
TMXRenderer

a TMX renderer


Powered by webdoc!