TMXRenderer

class TMXRenderer

The map renderer base class

Constructor


new TMXRenderer(cols: number, rows: number, tilewidth: number, tileheight: number) → {}
Parameters:
Name Type Description
cols number

width of the tilemap in tiles

rows number

height of the tilemap in tiles

tilewidth number

width of each tile in pixels

tileheight number

height of each tile in pixels

Public Methods


canRender TMXRenderer.js:26
canRender(component: TMXTileMap | TMXLayer) → {boolean}

return true if the renderer can render the specified map or layer

Parameters:
Name Type Description
component TMXTileMap | TMXLayer

TMX Map or Layer

Returns:
Type Description
boolean
drawTile TMXRenderer.js:81
drawTile(renderer: CanvasRenderer | WebGLRenderer, x: number, y: number, tile: Tile) → {}

draw the given tile at the specified layer

Parameters:
Name Type Description
renderer CanvasRenderer | WebGLRenderer

a renderer object

x number

X coordinate where to draw the tile

y number

Y coordinate where to draw the tile

tile Tile

the tile object to draw

drawTileLayer TMXRenderer.js:91
drawTileLayer(renderer: CanvasRenderer | WebGLRenderer, layer: TMXLayer, rect: Rect) → {}

draw the given TMX Layer for the given area

Parameters:
Name Type Description
renderer CanvasRenderer | WebGLRenderer

a renderer object

layer TMXLayer

a TMX Layer object

rect Rect

the area of the layer to draw

getBounds TMXRenderer.js:44
getBounds(layer: TMXLayer) → {Bounds}

return the bounding rect for this map renderer

Parameters:
Name Type Attributes Description
layer TMXLayer

<optional>

calculate the bounding rect for a specific layer (will return a new bounds object)

Returns:
Type Description
Bounds
pixelToTileCoords TMXRenderer.js:59
pixelToTileCoords(x: number, y: number, v: Vector2d) → {Vector2d}

return the tile position corresponding to the specified pixel

Parameters:
Name Type Attributes Description
x number

X coordinate

y number

Y coordinate

v Vector2d

<optional>

an optional vector object where to put the return values

Returns:
Type Description
Vector2d
tileToPixelCoords TMXRenderer.js:70
tileToPixelCoords(col: number, row: number, v: Vector2d) → {Vector2d}

return the pixel position corresponding of the specified tile

Parameters:
Name Type Attributes Description
col number

tile horizontal position

row number

tile vertical position

v Vector2d

<optional>

an optional vector object where to put the return values

Returns:
Type Description
Vector2d

Powered by webdoc!