LittleJS 1.30.1

Draw

TileInfo

Tile Info - Stores info about how to draw a tile

Constructor

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

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:195

Shrinks tile by this many pixels to prevent neighbors bleeding

columns : numberengineDraw.js:197

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

padding : numberengineDraw.js:187

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:193

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:214

Returns a copy of this tile offset by a number of animation frames

  • Frames step along the row and carry on at the start of the next row of the texture, counted as tile() counts, for a tile on the texture's grid as tile() makes them
  • With columns set they wrap down by that many frames from this one instead
frame number

Offset to apply in animation frames

index(index) → TileInfoengineDraw.js:253

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:204

Returns a copy of this tile offset by a vector

offset Vector2

Offset to apply in pixels

setColumns(columns) → TileInfoengineDraw.js:240

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:261

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

textureInfo TextureInfo optional