TMXRenderer
class TMXRenderer
The map renderer base class
Constructor
new TMXRenderer(cols: number, rows: number, tilewidth: number, tileheight: number) → {}
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 |
Summary
Methods from TMXRenderer
boolean |
|
|
|
|
|
Bounds |
|
Vector2d |
|
Vector2d |
|
Public Methods
canRender(component: TMXTileMap | TMXLayer) → {boolean}
return true if the renderer can render the specified map or layer
Name | Type | Description |
---|---|---|
component | TMXTileMap | TMXLayer |
TMX Map or Layer |
Type | Description |
---|---|
boolean |
drawTile(renderer: CanvasRenderer | WebGLRenderer, x: number, y: number, tile: Tile) → {}
draw the given tile at the specified layer
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(renderer: CanvasRenderer | WebGLRenderer, layer: TMXLayer, rect: Rect) → {}
draw the given TMX Layer for the given area
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(layer: TMXLayer) → {Bounds}
return the bounding rect for this map renderer
Name | Type | Attributes | Description |
---|---|---|---|
layer | TMXLayer |
<optional> |
calculate the bounding rect for a specific layer (will return a new bounds object) |
Type | Description |
---|---|
Bounds |
pixelToTileCoords(x: number, y: number, v: Vector2d) → {Vector2d}
return the tile position corresponding to the specified pixel
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 |
Type | Description |
---|---|
Vector2d |
tileToPixelCoords(col: number, row: number, v: Vector2d) → {Vector2d}
return the pixel position corresponding of the specified tile
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 |
Type | Description |
---|---|
Vector2d |