Package com.deco2800.game.input
Class CameraInputComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.input.InputComponent
com.deco2800.game.input.CameraInputComponent
- All Implemented Interfaces:
com.badlogic.gdx.input.GestureDetector.GestureListener
,com.badlogic.gdx.InputProcessor
-
Field Summary
Fields inherited from class com.deco2800.game.input.InputComponent
priority
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Called when the entity is created and registered.boolean
ifPaused()
boolean
mouseMoved
(int screenX, int screenY) boolean
scrolled
(float amountX, float amountY) Adjusts the camera zoom amount according to scroll speed.void
setMapDetails
(float tileSize, int mapWidth, int mapHeight) Sets the tile size from a terrainComponentvoid
update()
Moves the camera relative to the change and current speedvoid
Checks to see if the cursor is hovered to a screen edge, and if so updates the direction it must move incom.badlogic.gdx.math.GridPoint2
worldToTile
(float worldX, float worldY) Converts a world point to a position on the tile mapstatic com.badlogic.gdx.math.GridPoint2
worldToTile
(float tileSize, float worldX, float worldY) Converts a world point to a position on the tile mapMethods inherited from class com.deco2800.game.input.InputComponent
dispose, fling, getPriority, keyDown, keyTyped, keyUp, longPress, pan, panStop, pinch, pinchStop, pinchStopHandled, setPriority, tap, touchDown, touchDown, touchDragged, touchUp, zoom
Methods inherited from class com.deco2800.game.components.Component
earlyUpdate, getEntity, isAnimationRenderComponent, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
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 classInputComponent
-
mouseMoved
public boolean mouseMoved(int screenX, int screenY) - Specified by:
mouseMoved
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
mouseMoved
in classInputComponent
- See Also:
-
InputProcessor.mouseMoved(int, int)
-
update
public void update()Moves the camera relative to the change and current speed -
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 interfacecom.badlogic.gdx.InputProcessor
- Overrides:
scrolled
in classInputComponent
- 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 entityworldY
- 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 mapworldX
- world y position of an entityworldY
- world y position of an entity- Returns:
- position of the world point on the tile map
-