Class enchant.Map
A class to create and display maps from a tile set.
- Defined in: enchant.js
- Extends enchant.Entity
Constructor Attributes | Constructor Name and Description |
---|---|
enchant.Map(tileWidth, tileHeight)
|
Field Attributes | Field Name and Description |
---|---|
Two dimensional array to store if collision detection should be performed for a tile.
|
|
Image with which the tile set is displayed on the map.
|
|
Map tile height.
|
|
Map tile width.
|
- Fields borrowed from class enchant.Entity:
- backgroundColor, buttonMode, buttonPressed, compositeOperation, debugColor, height, opacity, originX, originY, rotation, scaleX, scaleY, touchEnabled, visible, width
- Fields borrowed from class enchant.Node:
- age, parentNode, scene, x, y
Method Summary
Method Attributes | Method Name and Description |
---|---|
checkTile(x, y)
Checks what tile is present at the given position.
|
|
hitTest(x, y)
Judges whether or not obstacles are on top of Map.
|
|
loadData(data)
Set map data.
|
- Methods borrowed from class enchant.Entity:
- disableCollection
- enableCollection
- intersect
- rotate
- scale
- within
- Methods borrowed from class enchant.Node:
- moveBy
- moveTo
- Methods borrowed from class enchant.EventTarget:
- addEventListener
- clearEventListener
- dispatchEvent
- on
- removeEventListener
Class Detail
enchant.Map(tileWidth, tileHeight)
- Parameters:
- {Number} tileWidth
- Tile width.
- {Number} tileHeight
- Tile height.
Field Detail
{Number[][]}
collisionData
Two dimensional array to store if collision detection should be performed for a tile.
{enchant.Surface}
image
Image with which the tile set is displayed on the map.
{Number}
tileHeight
Map tile height.
{Number}
tileWidth
Map tile width.
Method Detail
-
{*} checkTile(x, y)Checks what tile is present at the given position.
- Parameters:
- {Number} x
- x coordinates of the point on the map.
- {Number} y
- y coordinates of the point on the map.
- Returns:
- {*} The tile data for the given position.
-
{Boolean} hitTest(x, y)Judges whether or not obstacles are on top of Map.
- Parameters:
- {Number} x
- x coordinates of detection spot on map.
- {Number} y
- y coordinates of detection spot on map.
- Returns:
- {Boolean} True, if there are obstacles.
-
loadData(data)Set map data. Sets the tile data, whereas the data (two-dimensional array with indizes starting from 0) is mapped on the image starting from the upper left corner. When more than one map data array is set, they are displayed in reverse order.
- Parameters:
- {...Number[][]} data
- Two-dimensional array of tile indizes. Multiple designations possible.