Class TerrainComponent

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, Renderable, Comparable<Renderable>

public class TerrainComponent extends RenderComponent
Render a tiled terrain for a given tiled map and orientation. A terrain is a map of tiles that shows the 'ground' in the game. Enabling/disabling this component will show/hide the terrain.
  • Constructor Details

    • TerrainComponent

      public TerrainComponent(com.badlogic.gdx.graphics.OrthographicCamera camera, com.badlogic.gdx.maps.tiled.TiledMap map, com.badlogic.gdx.maps.tiled.TiledMapRenderer renderer, TerrainComponent.TerrainOrientation orientation, float tileSize)
  • Method Details

    • tileToWorldPosition

      public com.badlogic.gdx.math.Vector2 tileToWorldPosition(com.badlogic.gdx.math.GridPoint2 tilePos)
    • tileToWorldPosition

      public com.badlogic.gdx.math.Vector2 tileToWorldPosition(int x, int y)
    • getTileSize

      public float getTileSize()
    • getMapBounds

      public com.badlogic.gdx.math.GridPoint2 getMapBounds(int layer)
    • getMap

      public com.badlogic.gdx.maps.tiled.TiledMap getMap()
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Description copied from class: RenderComponent
      Draw the renderable. Should be called only by the renderer, not manually.
      Specified by:
      draw in class RenderComponent
      Parameters:
      batch - Batch to render to.
    • dispose

      public void dispose()
      Description copied from class: Component
      Called when the component is disposed. Dispose of any internal resources here.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class RenderComponent
    • getZIndex

      public float getZIndex()
      Description copied from interface: Renderable
      Z index controls rendering order within a layer. Higher Z index is drawn on top.
      Specified by:
      getZIndex in interface Renderable
      Overrides:
      getZIndex in class RenderComponent
      Returns:
      Z index
    • getLayer

      public int getLayer()
      Description copied from interface: Renderable
      Layer to be rendered in. Higher layers will be rendered on top of lower layers.
      Specified by:
      getLayer in interface Renderable
      Overrides:
      getLayer in class RenderComponent
      Returns:
      layer