TileSet
The TileSet class is used for drawing tiles from a tileset image.
Constructor
prototype
constructor(imageName: string, frameSize: Point, scale: Point = new Point(1, 1));
Parameters
imageName- Type:
string - The name of the image to use.
- Type:
frameSize- Type:
Point - The size of a single frame.
- Type:
scale(optional)- Type:
Point - Default value:
new Point(1, 1) - The scale of the tile.
- Type:
Examples
const tileSet = new TileSet('myImage', new Point(32, 32));
const tileSet = new TileSet('myImage', new Point(32, 32), new Point(2, 2));
Methods
drawTile
prototype
drawTile(context: CanvasRenderingContext2D, TileId: number, position: Point, useCache?: boolean): void;
Parameters
context- Type:
CanvasRenderingContext2D - The context to draw to on.
- Type:
TileId- Type:
number - The id of the tile to draw.
- Type:
position- Type:
Point - The position to draw the tile at.
- Type:
useCache- Type:
boolean - Default value:
undefined(disable cache system) - Whether or not to use the cache (use the cache improve performances).
- Type:
Return
void
Example
const tileSet = new TileSet(/* ... */);
//...
tileSet.drawTile(context, 0, new Point(0, 0));