# Layer (Slick - The 2D Library)
Date: 2013-06-03

## org.newdawn.slick.tiled
Class Layer

    java.lang.Object
      org.newdawn.slick.tiled.Layer

    public class Layer

extends java.lang.Object

A layer of tiles on the map

Author:
  kevin

Field Summary
`int[][][]` `data` The tile data representing this data, index 0 = tileset, index 1 = tile id
`int` `height` The height of this layer
`int` `index` The index of this layer
`java.lang.String` `name` The name of this layer - read from the XML
`java.util.Properties` `props` the properties of this layer
`int` `width` The width of this layer

Constructor Summary
`Layer(TiledMap map, org.w3c.dom.Element element)` Create a new layer based on the XML definition

Method Summary
`int` `getTileID(int x, int y)` Get the gloal ID of the tile at the specified location in this layer
`void` `render(int x, int y, int sx, int sy, int width, int ty, boolean lineByLine, int mapTileWidth, int mapTileHeight)` Render a section of this layer
`void` `setTileID(int x, int y, int tile)` Set the global tile ID at a specified location

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### index

    public int index

  The index of this layer

### name

    public java.lang.String name

  The name of this layer - read from the XML

### data

    public int[][][] data

  The tile data representing this data, index 0 = tileset, index 1 = tile id

### width

    public int width

  The width of this layer

### height

    public int height

  The height of this layer

### props

    public java.util.Properties props

  the properties of this layer

Constructor Detail

### Layer

    public Layer(TiledMap map,
                 org.w3c.dom.Element element)
          throws SlickException

  Create a new layer based on the XML definition

  Parameters:
    `element` - The XML element describing the layer
    `map` - The map this layer is part of
  Throws:
    `SlickException` - Indicates a failure to parse the XML layer

Method Detail

### getTileID

    public int getTileID(int x,
                         int y)

  Get the gloal ID of the tile at the specified location in this layer

  Parameters:
    `x` - The x coorindate of the tile
    `y` - The y coorindate of the tile
  Returns:
    The global ID of the tile

### setTileID

    public void setTileID(int x,
                          int y,
                          int tile)

  Set the global tile ID at a specified location

  Parameters:
    `x` - The x location to set
    `y` - The y location to set
    `tile` - The tile value to set

### render

    public void render(int x,
                       int y,
                       int sx,
                       int sy,
                       int width,
                       int ty,
                       boolean lineByLine,
                       int mapTileWidth,
                       int mapTileHeight)

  Render a section of this layer

  Parameters:
    `x` - The x location to render at
    `y` - The y location to render at
    `sx` - The x tile location to start rendering
    `sy` - The y tile location to start rendering
    `width` - The number of tiles across to render
    `ty` - The line of tiles to render
    `lineByLine` - True if we should render line by line, i.e. giving us a chance to render something else between lines
    `mapTileWidth` - the tile width specified in the map file
    `mapTileHeight` - the tile height specified in the map file

Copyright © 2006 New Dawn Software. All Rights Reserved.