Package com.screens
Class GameInputHandler
- java.lang.Object
-
- com.screens.GameInputHandler
-
- All Implemented Interfaces:
com.badlogic.gdx.InputProcessor
public class GameInputHandler extends java.lang.Object implements com.badlogic.gdx.InputProcessorInput handler processor forGameScreen
-
-
Constructor Summary
Constructors Constructor Description GameInputHandler(GameScreen gameScreen)Constructor for game input handler which takes in GameScreen to be able to provide some sort of feedback to when an event occurs
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleankeyDown(int keycode)Called when a key was pressedbooleankeyTyped(char character)Called when a key was typedbooleankeyUp(int keycode)Called when a key was releasedbooleanmouseMoved(int screenX, int screenY)Called when the mouse was moved without any buttons being pressed.booleanscrolled(int amount)Called when the mouse wheel was scrolled.booleantouchDown(int screenX, int screenY, int pointer, int button)Called when the screen was touched or a mouse button was pressed.booleantouchDragged(int screenX, int screenY, int pointer)Called when a finger or the mouse was dragged.booleantouchUp(int screenX, int screenY, int pointer, int button)Called when a finger was lifted or a mouse button was released.
-
-
-
Constructor Detail
-
GameInputHandler
public GameInputHandler(GameScreen gameScreen)
Constructor for game input handler which takes in GameScreen to be able to provide some sort of feedback to when an event occurs- Parameters:
gameScreen- GameScreen
-
-
Method Detail
-
keyDown
public boolean keyDown(int keycode)
Called when a key was pressed- Specified by:
keyDownin interfacecom.badlogic.gdx.InputProcessor- Parameters:
keycode- one of the constants inInput.Keys- Returns:
- whether the input was processed
-
keyUp
public boolean keyUp(int keycode)
Called when a key was released- Specified by:
keyUpin interfacecom.badlogic.gdx.InputProcessor- Parameters:
keycode- one of the constants inInput.Keys- Returns:
- whether the input was processed
-
keyTyped
public boolean keyTyped(char character)
Called when a key was typed- Specified by:
keyTypedin interfacecom.badlogic.gdx.InputProcessor- Parameters:
character- The character- Returns:
- whether the input was processed
-
touchDown
public boolean touchDown(int screenX, int screenY, int pointer, int button)Called when the screen was touched or a mouse button was pressed. The button parameter will beInput.Buttons.LEFTon iOS.- Specified by:
touchDownin interfacecom.badlogic.gdx.InputProcessor- Parameters:
screenX- The x coordinate, origin is in the upper left cornerscreenY- The y coordinate, origin is in the upper left cornerpointer- the pointer for the event.button- the button- Returns:
- whether the input was processed
-
touchUp
public boolean touchUp(int screenX, int screenY, int pointer, int button)Called when a finger was lifted or a mouse button was released. The button parameter will beInput.Buttons.LEFTon iOS.- Specified by:
touchUpin interfacecom.badlogic.gdx.InputProcessor- Parameters:
screenX- x coord of touchscreenY- y coord of touchpointer- the pointer for the event.button- the button- Returns:
- whether the input was processed
-
touchDragged
public boolean touchDragged(int screenX, int screenY, int pointer)Called when a finger or the mouse was dragged.- Specified by:
touchDraggedin interfacecom.badlogic.gdx.InputProcessor- Parameters:
screenX- x coord of touchscreenY- y coord of touchpointer- the pointer for the event.- Returns:
- whether the input was processed
-
mouseMoved
public boolean mouseMoved(int screenX, int screenY)Called when the mouse was moved without any buttons being pressed. Will not be called on iOS.- Specified by:
mouseMovedin interfacecom.badlogic.gdx.InputProcessor- Parameters:
screenX- x coord of touchscreenY- y coord of touch- Returns:
- whether the input was processed
-
scrolled
public boolean scrolled(int amount)
Called when the mouse wheel was scrolled. Will not be called on iOS.- Specified by:
scrolledin interfacecom.badlogic.gdx.InputProcessor- Parameters:
amount- the scroll amount, -1 or 1 depending on the direction the wheel was scrolled.- Returns:
- whether the input was processed.
-
-