Class KeyboardPlayerInputComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.input.InputComponent
com.csse3200.game.components.player.KeyboardPlayerInputComponent
- All Implemented Interfaces:
com.badlogic.gdx.input.GestureDetector.GestureListener
,com.badlogic.gdx.InputProcessor
Input handler for the player for keyboard and touch (mouse) input.
This input handler only uses keyboard input.
-
Field Summary
Fields inherited from class com.csse3200.game.input.InputComponent
priority
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor, adds values to the button pressed map to avoid player gaining unintended velocity when entering and exiting screens while holding a wasd button -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
keyDown
(int keycode) Triggers player events on specific keycodes.boolean
keyUp
(int keycode) Triggers player events on specific keycodes.void
paralyze()
void
Resets the player's velocity to 0, 'unpresses' all keys.boolean
scrolled
(float amountX, float amountY) Triggers camera zoom for player, calling the associated event listenervoid
void
update()
Called once per frame of the game, and should be used for most component logic.Methods inherited from class com.csse3200.game.input.InputComponent
create, dispose, fling, getPriority, keyTyped, longPress, mouseMoved, pan, panStop, pinch, pinchStop, pinchStopHandled, setPriority, tap, touchDown, touchDown, touchDragged, touchUp, zoom
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
KeyboardPlayerInputComponent
public KeyboardPlayerInputComponent()Constructor, adds values to the button pressed map to avoid player gaining unintended velocity when entering and exiting screens while holding a wasd button
-
-
Method Details
-
resetVelocity
public void resetVelocity()Resets the player's velocity to 0, 'unpresses' all keys. -
keyDown
public boolean keyDown(int keycode) Triggers player events on specific keycodes.- Specified by:
keyDown
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
keyDown
in classInputComponent
- Returns:
- whether the input was processed
- See Also:
-
keyUp
public boolean keyUp(int keycode) Triggers player events on specific keycodes.- Specified by:
keyUp
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
keyUp
in classInputComponent
- Returns:
- whether the input was processed
- See Also:
-
scrolled
public boolean scrolled(float amountX, float amountY) Triggers camera zoom for player, calling the associated event listener- Specified by:
scrolled
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
scrolled
in classInputComponent
- Parameters:
amountX
- the horizontal zoom amountamountY
- the vertical zoom amount- Returns:
- whether the input was processed
- See Also:
-
update
public void update()Description copied from class:Component
Called once per frame of the game, and should be used for most component logic. Not called if component is disabled. -
isParalyzed
public boolean isParalyzed() -
paralyze
public void paralyze() -
unParalyze
public void unParalyze()
-