new BufferBase(optionsopt)
Implements basic functionality for buffers and cell buffers.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
options |
BufferOptions |
<optional> |
An optional options object for configuring the buffer. |
Members
activeTilesMap :Object
A map of active tiles, with hashed tile positions as keys and an array of tiles at a position as values.
offsetPixels :Tily.utility.vec2
The offset of this buffer measured in pixels, as a Tily.utility.vec2 object.
(nullable) offsetTransition :Tily.OffsetTransition
The currently running offset transition or null if there is no transition currently running.
- Default Value:
- null
(nullable) scaleTransition :Tily.ScaleTransition
The currently running scale transition or null if there is no transition currently running.
- Default Value:
- null
Methods
addActiveTile(…tiles) → {Tily.ActiveTile|array}
Add an active tile or multiple active tiles to this buffer.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
tiles |
Tily.ActiveTile |
<repeatable> |
The tile(s) to add. |
getPosition(x, y) → {Tily.utility.vec2}
Return the tile position for the specified pixel position, based on the current offset and scale.
Parameters
Name | Type | Description |
---|---|---|
x |
number | The x-coordinate of the pixel position. |
y |
number | The y-coordinate of the pixel position. |
getTileInfo(x, y) → {BufferBaseTileInfo}
Get information about the active tiles at a tile position.
Parameters
Name | Type | Description |
---|---|---|
x |
number | The x-coordinate of the tile position. |
y |
number | The y-coordinate of the tile position. |
moveOffset(x, y, optionsopt)
Move the offset with an optional transition animation.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
x |
number | The x-coordinate of the target offset position. |
|
y |
number | The y-coordinate of the target offset position. |
|
options |
MoveOffsetTransitionOptions |
<optional> |
An optional options object. |
removeActiveTile(tile)
Remove an active tile from this buffer.
Parameters
Name | Type | Description |
---|---|---|
tile |
Tily.ActiveTile | The tile to remove. |
updateActiveTilesMap(tl, br) → {Array.<Tily.ActiveTile>}
Update the active tiles map and get a list of active tiles currently in view.
Parameters
Name | Type | Description |
---|---|---|
tl |
Tily.utility.vec2 | The top-left tile position currently in view. |
br |
Tily.utility.vec2 | The bottom-right tile position currently in view. |
updateTransitions(elapsedTime) → {Tily.utility.vec2}
Update offset and scale transitions.
Parameters
Name | Type | Description |
---|---|---|
elapsedTime |
number | The time elapsed in seconds since the last draw call. |
zoom(scale, optionsopt)
Zoom the scale with an optional transition animation.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
scale |
number | The target scale. |
|
options |
TransitionOptions |
<optional> |
An optional options object. |