new Cell(buffer)
A rectangular cell of tiles displayed in a cell buffer.
Parameters
Name | Type | Description |
---|---|---|
buffer |
Tily.CellBuffer | The cell buffer that this cell belongs to. |
Members
Methods
(static) deserialize(buffer, s) → {Tily.Cell}
Deserialize the JSON data into a cell.
Parameters
Name | Type | Description |
---|---|---|
buffer |
Tily.CellBuffer | The cell buffer that the cell belongs to. |
s |
string | The JSON data to deserialize. |
(static) fromData(buffer, data) → {Tily.Cell}
Create a cell from data.
Parameters
Name | Type | Description |
---|---|---|
buffer |
Tily.CellBuffer | The cell buffer that the cell belongs to. |
data |
Object | Serialized cell data. |
addLayer(layer, zopt)
Add a layer to this cell at the specified z-index. If the z-index is undefined, add the layer on top of existing layers, and if the z-index is -1, add the layer below existing layers.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
layer |
Tily.TileLayer | The layer to add. |
|
z |
number |
<optional> |
The z-index at which to add the layer. If this is -1, the layer will be added below existing layers and if it is undefined the layer will be added above existing layers. |
draw(context, elapsedTime, x, y, tileSize, tl, br, activeTiles)
Render this layer onto the specified context.
Parameters
Name | Type | Description |
---|---|---|
context |
CanvasRenderingContext2D | The context to render the layer onto. |
elapsedTime |
number | The time elapsed in seconds since the last draw call. |
x |
number | The cell x-coordinate. |
y |
number | The cell y-coordinate. |
tileSize |
number | The size of each tile measured in pixels. |
tl |
Tily.utility.vec2 | The top-left tile position currently in view. |
br |
Tily.utility.vec2 | The bottom-right tile position currently in view. |
activeTiles |
Array.<Tily.ActiveTile> | A list of active tiles currently in view, sorted by z-index (ascending). |
moveLayer(zFrom, zTo, relative) → {boolean}
Move a layer from one z-index to another z-index, either an absolute value or relative to the layer's current z-index.
Parameters
Name | Type | Description |
---|---|---|
zFrom |
number | The z-index of the layer to move. |
zTo |
number | The z-index to move the layer to. |
relative |
boolean | If this is true, the layer will be moved relative to it's current z-index. |
Returns
True if a layer was moved successfully.
- Type
- boolean
removeLayer(zopt) → {Tily.TileLayer}
Remove a layer at the specified z-index. If the z-index is undefined, remove the top layer and if the z-index is -1, remove the bottom layer. The removed layer is returned.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
z |
number |
<optional> |
The z-index of the layer to remove. If this is -1, the bottom layer will be removed and if it is undefined the top layer will be removed. |