API Docs for:
Show:

RendererLayer Class

Represents a map tile layer to be rendered.

Constructor

RendererLayer

(
  • game
  • type
)

Parameters:

  • game Game
    • Game instance this obj is attached to.
  • type String
    • Type of RendererLayer. When created this object is merged with the value of RendererLayer.Types[type].

Methods

getModifiedTileData

(
  • x
  • y
  • [prevTileData]
)
TileData | Bool

Get layer's TileData for a given map tile coord. Optionally modifying the prevTileData object param if this.mergeWithPrevLayer = true.

Parameters:

  • x Number
    • Map tile x coord.
  • y Object
    • Map tile y coord.
  • [prevTileData] Object optional
    • tileData object for the given map tile coord from previous layer.

Returns:

TileData | Bool:

false if nothing to render

getTileData

(
  • x
  • y
  • [prevTileData]
)
TileData | Bool

Get layer's tileData for a given map tile coord.

Parameters:

  • x Number
    • Map tile x coord.
  • y Object
    • Map tile y coord.
  • [prevTileData] Object optional
    • tileData object for the given map tile coord from previous layer.

Returns:

TileData | Bool:

false if nothing to render

mergeTileData

(
  • tileData1
  • tileData2
)
TileData

Merges 2 tileData objects. Used to Merges layers of the same tile before drawing them.

Parameters:

  • tileData1 TileData
    • tileData to merge to.
  • tileData2 TileData
    • tileData to merge from, properties with values on tileData2 replace matching properties on tileData1

Returns:

TileData:

A new tileData object with merged values.

Properties

afterDraw

Function function(x, y, tileData, ctx)

After draw function. Ignored if this.draw = false.

beforeDraw

Function function(x, y, tileData, ctx)

Before draw function. Ignored if this.draw = false.

cancelTileDrawWhenNotFound

Boolean

If true, when this.getTileData(x, y) returns a value that evaluates to false, all tile layers above this one are not drawn by the Renderer for this map tile coord.

draw

Boolean

If true, tileData is drawn to the canvas after processing this layer.

game

Game

Game instance this obj is attached to.

mergeWithPrevLayer

Boolean

If true, this.getTileData() will merge the tileData it would otherwise return with the prevTileData param (if provided). objects are from this layer should be merged with layers below before drawing.

type

String

The type of RendererLayer this is. When created this object is merged with the value of RendererLayer.Types[type]. See constructor.