Class CameraInputComponent

All Implemented Interfaces:
com.badlogic.gdx.input.GestureDetector.GestureListener, com.badlogic.gdx.InputProcessor

public class CameraInputComponent extends InputComponent
  • Constructor Details

    • CameraInputComponent

      public CameraInputComponent()
  • Method Details

    • ifPaused

      public boolean ifPaused()
    • create

      public void create()
      Description copied from class: Component
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
      Overrides:
      create in class InputComponent
    • mouseMoved

      public boolean mouseMoved(int screenX, int screenY)
      Specified by:
      mouseMoved in interface com.badlogic.gdx.InputProcessor
      Overrides:
      mouseMoved in class InputComponent
      See Also:
      • InputProcessor.mouseMoved(int, int)
    • update

      public void update()
      Moves the camera relative to the change and current speed
      Overrides:
      update in class Component
    • updateDirection

      public void updateDirection()
      Checks to see if the cursor is hovered to a screen edge, and if so updates the direction it must move in
    • scrolled

      public boolean scrolled(float amountX, float amountY)
      Adjusts the camera zoom amount according to scroll speed.
      Specified by:
      scrolled in interface com.badlogic.gdx.InputProcessor
      Overrides:
      scrolled in class InputComponent
      See Also:
      • InputProcessor.scrolled(float, float)
    • setMapDetails

      public void setMapDetails(float tileSize, int mapWidth, int mapHeight)
      Sets the tile size from a terrainComponent
      Parameters:
      tileSize - tileSize in current game
    • worldToTile

      public com.badlogic.gdx.math.GridPoint2 worldToTile(float worldX, float worldY)
      Converts a world point to a position on the tile map
      Parameters:
      worldX - world y position of an entity
      worldY - world y position of an entity
      Returns:
      position of the world point on the tile map
    • worldToTile

      public static com.badlogic.gdx.math.GridPoint2 worldToTile(float tileSize, float worldX, float worldY)
      Converts a world point to a position on the tile map
      Parameters:
      tileSize - tileSize returned by TerrainComponent of map
      worldX - world y position of an entity
      worldY - world y position of an entity
      Returns:
      position of the world point on the tile map