Class Layer

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

public class Layer extends Object

A named drawing band in a GameLevel: the editor's "Background / Terrain / Items / Actors" rows, and the rendering order behind them.

A layer has a #getKind() -- Kind#TILE layers paint a grid of asset ids into cells (stored as a "col,row" -> assetId map), while Kind#ENTITY and Kind#MODEL layers just group freely-placed GameElements. #isVisible() and #isLocked() mirror the editor toggles; #getBand() is the layer's slot in the stack and is folded into the rendered z-order (band * 1000 + per-sprite z) so a higher layer always draws over a lower one.

  • Constructor Details

  • Method Details

    • getName

      public String getName()
    • setName

      public Layer setName(String name)
    • getKind

      public Layer.Kind getKind()
      What this layer holds (Kind#TILE / Kind#ENTITY / Kind#MODEL).
    • setKind

      public Layer setKind(Layer.Kind kind)
    • isVisible

      public boolean isVisible()
    • setVisible

      public Layer setVisible(boolean visible)
    • isLocked

      public boolean isLocked()
    • setLocked

      public Layer setLocked(boolean locked)
    • getBand

      public int getBand()
    • setBand

      public Layer setBand(int band)
    • getParallaxX

      public float getParallaxX()
      The horizontal parallax factor applied to every sprite realized from this layer (default 1 = scrolls with the world). A background layer of clouds/mountains uses a small factor (e.g. 0.3) so it drifts behind the foreground as the camera scrolls.
    • getParallaxY

      public float getParallaxY()
      The vertical parallax factor for this layer (default 1); see #getParallaxX().
    • setParallax

      public Layer setParallax(float x, float y)
    • tiles

      public Map<String,String> tiles()
      The raw "col,row" -> assetId map for a tile layer.
    • cellKey

      public static String cellKey(int col, int row)
      The cell key used in the tile map for a column and row.
    • putTile

      public Layer putTile(int col, int row, String assetId)
      Paints an asset into a tile cell (no-op safety: a null assetId clears it).
    • getTile

      public String getTile(int col, int row)
      The asset id painted at a cell, or null if the cell is empty.
    • removeTile

      public Layer removeTile(int col, int row)