Constructor
new TilemapLayer(map, dataopt)
Creates a new object of TilemapLayer.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
map |
rune.tilemap.Tilemap | Reference to the map to which the layer belongs. | |
data |
Array.<number> |
<optional> |
Tilemap data. |
- Source:
- See:
Members
(readonly) data :Array.<number>
Reference to the raw map data of the layer, i.e., an array containing all
map indices. Note that this reference is intended for read-only purposes;
avoid modifying this list directly.
Type:
- Array.<number>
- Source:
(readonly) paths :rune.util.Paths
A stack of Path objects. Each object included in the stack is rendered on
top of the layer. Used primarily for troubleshooting.
Type:
- Source:
Methods
clear() → {undefined}
Clears all map data.
- Source:
Returns:
- Type
- undefined
getTileAt(i) → {rune.tilemap.Tile}
Returns a Tile object based on a specified tile index.
Parameters:
Name | Type | Description |
---|---|---|
i |
number | Tile index. |
- Source:
Returns:
- Type
- rune.tilemap.Tile
getTileIndexesIn(x, y, w, h) → {Array.<number>}
Returns a list of Tile indices that fit within a specified rectangular area.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x-coordinate of the clipping area. |
y |
number | The y-coordinate of the clipping area. |
w |
number | The width of the clipping area. |
h |
number | The height of the clipping area. |
- Source:
Returns:
- Type
- Array.<number>
getTileIndexesInRect(r) → {Array.<number>}
Returns a list of Tile indices contained within a described Rectangle object.
Parameters:
Name | Type | Description |
---|---|---|
r |
rune.geom.Rectangle | Rectangle object. |
- Source:
Returns:
- Type
- Array.<number>
getTileIndexOf(x, y) → {number}
Returns the tile index of a specific position.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x-coordinate of the position. |
y |
number | The y-coordinate of the position. |
- Source:
Returns:
- Type
- number
getTileIndexOfPoint(p) → {number}
Returns the tile index of a specific position, via a Point object.
Parameters:
Name | Type | Description |
---|---|---|
p |
rune.geom.Point | Point object. |
- Source:
Returns:
- Type
- number
getTileOf(x, y) → {rune.tilemap.Tile}
Returns a Tile object based on the given x and y coordinates.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | X coordinate. |
y |
number | Y coordinate. |
- Source:
Returns:
- Type
- rune.tilemap.Tile
getTileOfPoint(p) → {rune.tilemap.Tile}
Returns a Tile object based on the specified Point object.
Parameters:
Name | Type | Description |
---|---|---|
p |
rune.geom.Point | Point object. |
- Source:
Returns:
- Type
- rune.tilemap.Tile
getTileValueAt(i) → {number}
Returns the tile value of a specific tile index.
Parameters:
Name | Type | Description |
---|---|---|
i |
number | Tile index. |
- Source:
Returns:
- Type
- number
getTileValueOf(x, y) → {number}
Returns the tile value of a specific position.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x-coordinate of the position. |
y |
number | The y-coordinate of the position. |
- Source:
Returns:
- Type
- number
getTileValueOfPoint(p) → {number}
Return the tile value of a specific position, which is defined via a
Point object.
Parameters:
Name | Type | Description |
---|---|---|
p |
rune.geom.Point | Point object. |
- Source:
Returns:
- Type
- number
getTileValuesInRect(r) → {Array.<number>}
Returns tile values that fit within a specific rectangle object (clipping area).
Parameters:
Name | Type | Description |
---|---|---|
r |
rune.geom.Rectangle | Rectangle object. |
- Source:
Returns:
- Type
- Array.<number>
hitTest(obj, callbackopt, scopeopt) → {boolean}
Evaluates whether the tilemap layer overlaps or intersects another object.
This process only includes tiles that are solid ie. which has some form
of collision data associated with it.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
rune.display.DisplayObjectContainer | rune.display.InteractiveObject | rune.display.DisplayGroup | rune.geom.Point | Array | The object to be evaluated. | |
callback |
function |
<optional> |
Executed for each detected collision. |
scope |
Object |
<optional> |
Scope of execution for the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestAndSeparate(obj, callbackopt, scopeopt) → {boolean}
Evaluates and resolves collision between the tilemap layer and an interactive object's hitbox.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
rune.display.Stage | rune.display.InteractiveObject | rune.display.DisplayGroup | Array | The object to be evaluated. | |
callback |
function |
<optional> |
Executed for each detected collision. |
scope |
Object |
<optional> |
Scope of execution for the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestAndSeparateChildrenOf(parent, callbackopt, scopeopt) → {boolean}
Evaluates and resolves collision between the tilemap layer and the hitbox of child objects of the specified parent object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
parent |
rune.display.DisplayObjectContainer | The parent object to evaluate. | |
callback |
function |
<optional> |
Executed for each detected collision. |
scope |
Object |
<optional> |
Scope of execution for the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestAndSeparateContentOf(array, callbackopt, scopeopt) → {boolean}
Calculates and resolves collision between a Tilemap layer and
objects in an array.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
array |
Array | The array object to evaluate. | |
callback |
function |
<optional> |
Executed for each detected collision. |
scope |
Object |
<optional> |
Scope of execution for the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestAndSeparateGroup(group, callbackopt, scopeopt) → {boolean}
Evaluates and resolves collision between the tilemap layer and the hitbox of the members of the specified group object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
group |
rune.display.DisplayGroup | The group to evaluate. | |
callback |
function |
<optional> |
Executed for each detected collision. |
scope |
Object |
<optional> |
Scope of execution for the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestAndSeparateObject(obj, callbackopt, scopeopt) → {boolean}
Evaluates and resolves collision between the tilemap layer and the hitbox of an interactive object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
rune.display.InteractiveObject | The obje5 ct to evaluate. | |
callback |
function |
<optional> |
Executed for each detected collision. |
scope |
Object |
<optional> |
Scope of execution for the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestChildrenOf(parent, callbackopt, scopeopt) → {boolean}
Evaluates whether the tilemap layer overlaps or intersects the hitbox
of any of the child objects within the specified parent object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
parent |
rune.display.DisplayObjectContainer | The object to evaluate. | |
callback |
function |
<optional> |
Executed for each detected collision. |
scope |
Object |
<optional> |
Scope of execution for the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestContentOf(array, callbackopt, scopeopt) → {boolean}
Evaluates whether the tilemap layer overlaps or intersects the hitbox
of any of the contents of an array.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
array |
Array | The array to evaluate. | |
callback |
function |
<optional> |
Executed for each detected collision. |
scope |
Object |
<optional> |
Scope of execution for the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestGroup(group, callbackopt, scopeopt) → {boolean}
Evaluates whether the tilemap layer overlaps or intersects the hitbox of
any of the members within the specified group.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
group |
rune.display.DisplayGroup | The group to evaluate. | |
callback |
function |
<optional> |
Executed for each detected collision. |
scope |
Object |
<optional> |
Scope of execution for the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestObject(obj, callbackopt, scopeopt) → {boolean}
Evaluates whether the tilemap layer overlaps or intersects the hitbox of
another interactive object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
rune.display.InteractiveObject | The object to evaluate. | |
callback |
function |
<optional> |
Executed for each detected collision. |
scope |
Object |
<optional> |
Scope of execution for the callback method. |
- Source:
Returns:
- Type
- boolean
hitTestPoint(point, callbackopt, scopeopt) → {boolean}
Evaluates whether the specified Point object overlaps a solid tile in
the tilemap layer.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
point |
rune.geom.Point | The point to evaluate. | |
callback |
function |
<optional> |
Executed for each detected collision. |
scope |
Object |
<optional> |
Scope of execution for the callback method. |
- Source:
Returns:
- Type
- boolean
setTileValueAt(i, v) → {undefined}
Sets a tile value at a specified index.
Parameters:
Name | Type | Description |
---|---|---|
i |
number | Index. |
v |
number | Value. |
- Source:
Returns:
- Type
- undefined
setTileValueIn(x, y, w, h, v) → {undefined}
Sets a tile value for all tiles that fit within a specific rectangular area.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x-position of the area. |
y |
number | The y-position of the area. |
w |
number | The width of the area. |
h |
number | The height of the area. |
v |
number | The value to be set. |
- Source:
Returns:
- Type
- undefined
setTileValueInRect(r, v) → {undefined}
Sets a tile value for all tiles that fit within a specific rectangular area,
where the area is represented by a Rectangle object.
Parameters:
Name | Type | Description |
---|---|---|
r |
rune.geom.Rectangle | Rectangle object. |
v |
number | The value to be set. |
- Source:
Returns:
- Type
- undefined
setTileValueOf(x, y, v) → {undefined}
Sets a tile value for a tile at a specific position.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x-coordinate of the position. |
y |
number | The y-coordinate of the position. |
v |
number | The value to be set. |
- Source:
Returns:
- Type
- undefined
setTileValueOfPoint(p, v) → {undefined}
Sets a tile value for a tile at a specific position, where the position consists of a Point object.
Parameters:
Name | Type | Description |
---|---|---|
p |
rune.geom.Point | Point object. |
v |
number | The value to be set. |
- Source:
Returns:
- Type
- undefined