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);
Name | Type | Description |
---|---|---|
levelId | string |
name of TMX map |
data | object |
TMX map in JSON format |
Summary
Properties from TMXTileMap
string |
|
number |
|
number |
|
string |
|
string |
|
string |
|
number |
|
string |
|
number |
|
number |
|
string |
|
Methods from TMXTileMap
|
|
destroy function, clean all allocated objects |
|
Bounds |
|
Array<TMXLayer> |
|
Array<Renderable> |
|
TMXRenderer |
|
Public Properties
orientation: string = "orthogonal"
string
the map orientation type. melonJS supports “orthogonal”, “isometric”, “staggered” and “hexagonal”.
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")
tiledversion: string
string
The Tiled version used to save the file (since Tiled 1.0.1).
Public Methods
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);
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
container | Container |
target container |
||
flatten | boolean |
<optional> |
true |
if true, flatten all objects into the given container, else a |
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. |
getBounds() → {Bounds}
return the map bounding rect
Type | Description |
---|---|
Bounds |
getLayers() → {Array<TMXLayer>}
return all the existing layers
Type | Description |
---|---|
Array<TMXLayer> |
Array of Layers |
getObjects(flatten: boolean) → {Array<Renderable>}
return an Array of instantiated objects, based on the map object definition
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
flatten | boolean |
<optional> |
true |
if true, flatten all objects into the returned array.
when false, a |
Type | Description |
---|---|
Array<Renderable> |
Array of Objects |
getRenderer() → {TMXRenderer}
Return the map default renderer
Type | Description |
---|---|
TMXRenderer |
a TMX renderer |