public class TileLayer

  1. Object
  2. TileLayer

An efficient, single-tileset tile grid: a #getCols() x #getRows() array of frame indices into one SpriteSheet (-1 means “empty cell”).

This is the fast representation a game uses when every tile comes from the same atlas – contrast with a Layer of Layer.Kind#TILE, which stores an assetId-per-cell map and can mix assets from different packs. #toScene(Scene, int) materializes the non-empty cells as Sprites anchored at their top-left at tileSize spacing.

Constructors

public TileLayer(SpriteSheet sheet, int cols, int rows, int tileSize)

Methods

public int getCols()
public int getRows()
public int getTileSize()
public SpriteSheet getSheet()
public int getTile(int col, int row)The frame index painted at a cell, or -1 if empty.
public TileLayer setTile(int col, int row, int frame)Paints a frame index into a cell (-1 clears it).
public void toScene(Scene scene, int zOrder)Adds a Sprite for every non-empty cell to the scene, anchored at the cell’s top-left corner and z-ordered at zOrder.

Inherited methods

Constructor details

TileLayer

public TileLayer(SpriteSheet sheet, int cols, int rows, int tileSize)

Method details

getCols

public int getCols()

getRows

public int getRows()

getTileSize

public int getTileSize()

getSheet

public SpriteSheet getSheet()

getTile

public int getTile(int col, int row)
The frame index painted at a cell, or -1 if empty.

setTile

public TileLayer setTile(int col, int row, int frame)
Paints a frame index into a cell (-1 clears it).

toScene

public void toScene(Scene scene, int zOrder)
Adds a Sprite for every non-empty cell to the scene, anchored at the cell’s top-left corner and z-ordered at zOrder.