Class KeyboardTractorInputComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.input.InputComponent
com.csse3200.game.components.tractor.KeyboardTractorInputComponent
- All Implemented Interfaces:
com.badlogic.gdx.input.GestureDetector.GestureListener
,com.badlogic.gdx.InputProcessor
,com.badlogic.gdx.utils.Json.Serializable
-
Field Summary
Fields inherited from class com.csse3200.game.input.InputComponent
priority
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for the tractor, sets same priority as the player's input constructor -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.math.Vector2
Returns the direction the tractor is moving.boolean
keyDown
(int keycode) Triggers tractor events on specific keycodes.boolean
keyUp
(int keycode) Triggers tractor events on specific keycodes.void
setWalkDirection
(com.badlogic.gdx.math.Vector2 direction) Sets the movement direction of the tractor to a given direction.Methods inherited from class com.csse3200.game.input.InputComponent
create, dispose, fling, getPriority, keyTyped, longPress, mouseMoved, pan, panStop, pinch, pinchStop, pinchStopHandled, scrolled, setPriority, tap, touchDown, touchDown, touchDragged, touchUp, zoom
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, read, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update, write
-
Constructor Details
-
KeyboardTractorInputComponent
public KeyboardTractorInputComponent()Constructor for the tractor, sets same priority as the player's input constructor
-
-
Method Details
-
keyDown
public boolean keyDown(int keycode) Triggers tractor events on specific keycodes.- Specified by:
keyDown
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
keyDown
in classInputComponent
- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.keyDown(int)
-
keyUp
public boolean keyUp(int keycode) Triggers tractor events on specific keycodes.- Specified by:
keyUp
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
keyUp
in classInputComponent
- Returns:
- whether the input was processed
- See Also:
-
InputProcessor.keyUp(int)
-
getWalkDirection
public com.badlogic.gdx.math.Vector2 getWalkDirection()Returns the direction the tractor is moving. Called walkDirection for consistency with the player- Returns:
- the direction the tractor is moving as a Vector
-
setWalkDirection
public void setWalkDirection(com.badlogic.gdx.math.Vector2 direction) Sets the movement direction of the tractor to a given direction. Used to align player and tractor movement when getting in and out.- Parameters:
direction
- - The direction to set the walkDirection of the tractor.
-