Class: TileData

TileData()

Holds all of the tile data.

Constructor

new TileData()

Source:

Members

data

All of the tile data in a single Uint8ClampedArray. This is whats used by Screen to draw tiles.
Source:

flagData

All of the flag data in a single Uint16Array. Each item is a flag value for each tile.
Source:

tileSize

The size of each tile in pixels. Used for both width and height.
Source:

tilesets

Array of tileset data. All tiledata is added to this.data when init is called. More tilesets can not be added after this.
Source:

Methods

addTileset(tileset)

Add a tileset. All tilesets must be added before init is called.
Parameters:
Name Type Description
tileset Object the tileset data
Source:

getFlag(gid, flagNumber)

Get flag for a gid. If the flagNumber is not specified or negative, returns the bit field for a gid
Parameters:
Name Type Description
gid number the gid of the tile
flagNumber number the flag number, 0 - 15. If negative the number of the bit field will be returned
Source:

getGid(x, y, tileset)

Get the GID for a tile
Parameters:
Name Type Default Description
x number x position of the tile
y number y position of the tile
tileset number 0 the index of the tileset
Source:

getTileSectionData(gid, tileWidth, tileHeight)

Get the array data for a tile section
Parameters:
Name Type Default Description
gid number the gid of the bottom left tile
tileWidth number 1 the width in tiles of the tile section
tileHeight number 1 the height in tiles of the tile section
Source:

getTilesetInfoForGid(gid)

Get the tileset info for a given gid
Parameters:
Name Type Description
gid number the gid of the tile
Source:

init()

Parse all of the tilesets and add them to the data array
Source:

setFlag(gid, flagNumber, value)

Set flag for a gid. If the flagNumber is negative, set the bit field for a gid
Parameters:
Name Type Description
gid number the gid of the tile
flagNumber number the flag number, 0 - 15. Set negative to set the entire bit field for the flags
value number | boolean true or false if setting a flag, number if setting the bit field
Source: