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

  • 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.