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 TypeMethodDescriptionvoidcreate()Called when the entity is created and registered.booleanifPaused()booleanmouseMoved(int screenX, int screenY) booleanscrolled(float amountX, float amountY) Adjusts the camera zoom amount according to scroll speed.voidsetMapDetails(float tileSize, int mapWidth, int mapHeight) Sets the tile size from a terrainComponentvoidupdate()Moves the camera relative to the change and current speedvoidChecks to see if the cursor is hovered to a screen edge, and if so updates the direction it must move incom.badlogic.gdx.math.GridPoint2worldToTile(float worldX, float worldY) Converts a world point to a position on the tile mapstatic com.badlogic.gdx.math.GridPoint2worldToTile(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, zoomMethods 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:ComponentCalled 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:
createin classInputComponent
-
mouseMoved
public boolean mouseMoved(int screenX, int screenY) - Specified by:
mouseMovedin interfacecom.badlogic.gdx.InputProcessor- Overrides:
mouseMovedin 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:
scrolledin interfacecom.badlogic.gdx.InputProcessor- Overrides:
scrolledin 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
-