LittleJS 1.28.0

Draw

TileInfo

Tile Info - Stores info about how to draw a tile

Constructor

new TileInfo(pos, size, textureInfo, padding, bleed, columns)engineDraw.js:169

Create a tile info object

pos Vector2 optional, default vec2()

Top left corner of tile in pixels

size Vector2 optional

Size of tile in pixels

textureInfo TextureInfo optional

Texture info to use

padding number optional

How many pixels padding around all sides of each tile (increases grid size, does not affect tile size)

bleed number optional

How many pixels smaller to shrink UVS of tiles (does not affect grid size, only UVs)

columns number optional, default 0

How many frames per row for frame(), 0 to keep frames on a single row

Members

Methods

Members

bleed : numberengineDraw.js:194

Shrinks tile by this many pixels to prevent neighbors bleeding

columns : numberengineDraw.js:196

How many frames per row for frame(), 0 to keep frames on a single row

padding : numberengineDraw.js:186

How many pixels padding around tiles

Top left corner of tile in pixels

Size of tile in pixels

The texture info for this tile

tiles : Array<TileInfo>|undefinedengineDraw.js:192

A tile set's tiles, each wherever it was packed, as loadTiles makes them: a tile layer given this tile info draws its tile n from tiles[n] and not from a grid on one sheet

Methods

frame(frame) → TileInfoengineDraw.js:211

Returns a copy of this tile offset by a number of animation frames Frames wrap down to the next row if columns is set

frame number

Offset to apply in animation frames

index(index) → TileInfoengineDraw.js:240

Returns a tile info for an index using this tile's size, texture and padding as reference

  • the index counts from the texture's origin like tile(), for a sprite packed in a texture sheet use frame()
index Vector2|number optional, default 0
offset(offset) → TileInfoengineDraw.js:203

Returns a copy of this tile offset by a vector

offset Vector2

Offset to apply in pixels

setColumns(columns) → TileInfoengineDraw.js:227

Set how many frames per row this tile uses, so frame() can wrap

columns number optional, default 0

Frames per row, 0 to keep frames on a single row

setFullImage(textureInfo) → TileInfoengineDraw.js:248

Set this tile to use a full image in a texture info

textureInfo TextureInfo optional