# Class TileLayer

java.lang.Object
com.codename1.gaming.level.TileLayer

public class TileLayer extends Object

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 `Sprite`s anchored at their top-left at `tileSize` spacing.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TileLayer(SpriteSheet sheet, int cols, int rows, int tileSize)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getCols()`
  `int`
  `getRows()`
  `SpriteSheet`
  `getSheet()`
  `int`
  `getTile(int col, int row)`
  The frame index painted at a cell, or -1 if empty.
  `int`
  `getTileSize()`
  `TileLayer`
  `setTile(int col, int row, int frame)`
  Paints a frame index into a cell (-1 clears it).
  `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`.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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`.