Class InputAdapter

java.lang.Object
com.badlogic.gdx.InputAdapter
All Implemented Interfaces:
InputProcessor
Direct Known Subclasses:
FirstPersonCameraController, GestureDetector, Stage

public class InputAdapter extends Object implements InputProcessor
An adapter class for InputProcessor. You can derive from this and only override what you are interested in.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    keyDown(int keycode)
    Called when a key was pressed
    boolean
    keyTyped(char character)
    Called when a key was typed
    boolean
    keyUp(int keycode)
    Called when a key was released
    boolean
    mouseMoved(int screenX, int screenY)
    Called when the mouse was moved without any buttons being pressed.
    boolean
    scrolled(float amountX, float amountY)
    Called when the mouse wheel was scrolled.
    boolean
    touchCancelled(int screenX, int screenY, int pointer, int button)
    Called when the touch gesture is cancelled.
    boolean
    touchDown(int screenX, int screenY, int pointer, int button)
    Called when the screen was touched or a mouse button was pressed.
    boolean
    touchDragged(int screenX, int screenY, int pointer)
    Called when a finger or the mouse was dragged.
    boolean
    touchUp(int screenX, int screenY, int pointer, int button)
    Called when a finger was lifted or a mouse button was released.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InputAdapter

      public InputAdapter()
  • Method Details

    • keyDown

      public boolean keyDown(int keycode)
      Description copied from interface: InputProcessor
      Called when a key was pressed
      Specified by:
      keyDown in interface InputProcessor
      Parameters:
      keycode - one of the constants in Input.Keys
      Returns:
      whether the input was processed
    • keyUp

      public boolean keyUp(int keycode)
      Description copied from interface: InputProcessor
      Called when a key was released
      Specified by:
      keyUp in interface InputProcessor
      Parameters:
      keycode - one of the constants in Input.Keys
      Returns:
      whether the input was processed
    • keyTyped

      public boolean keyTyped(char character)
      Description copied from interface: InputProcessor
      Called when a key was typed
      Specified by:
      keyTyped in interface InputProcessor
      Parameters:
      character - The character
      Returns:
      whether the input was processed
    • touchDown

      public boolean touchDown(int screenX, int screenY, int pointer, int button)
      Description copied from interface: InputProcessor
      Called when the screen was touched or a mouse button was pressed. The button parameter will be Input.Buttons.LEFT on iOS.
      Specified by:
      touchDown in interface InputProcessor
      Parameters:
      screenX - The x coordinate, origin is in the upper left corner
      screenY - The y coordinate, origin is in the upper left corner
      pointer - 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)
      Description copied from interface: InputProcessor
      Called when a finger was lifted or a mouse button was released. The button parameter will be Input.Buttons.LEFT on iOS.
      Specified by:
      touchUp in interface InputProcessor
      pointer - the pointer for the event.
      button - the button
      Returns:
      whether the input was processed
    • touchCancelled

      public boolean touchCancelled(int screenX, int screenY, int pointer, int button)
      Description copied from interface: InputProcessor
      Called when the touch gesture is cancelled. Reason may be from OS interruption to touch becoming a large surface such as the user cheek). Relevant on Android and iOS only. The button parameter will be Input.Buttons.LEFT on iOS.
      Specified by:
      touchCancelled in interface InputProcessor
      pointer - the pointer for the event.
      button - the button
      Returns:
      whether the input was processed
    • touchDragged

      public boolean touchDragged(int screenX, int screenY, int pointer)
      Description copied from interface: InputProcessor
      Called when a finger or the mouse was dragged.
      Specified by:
      touchDragged in interface InputProcessor
      pointer - the pointer for the event.
      Returns:
      whether the input was processed
    • mouseMoved

      public boolean mouseMoved(int screenX, int screenY)
      Description copied from interface: InputProcessor
      Called when the mouse was moved without any buttons being pressed. Will not be called on iOS.
      Specified by:
      mouseMoved in interface InputProcessor
      Returns:
      whether the input was processed
    • scrolled

      public boolean scrolled(float amountX, float amountY)
      Description copied from interface: InputProcessor
      Called when the mouse wheel was scrolled. Will not be called on iOS.
      Specified by:
      scrolled in interface InputProcessor
      Parameters:
      amountX - the horizontal scroll amount, negative or positive depending on the direction the wheel was scrolled.
      amountY - the vertical scroll amount, negative or positive depending on the direction the wheel was scrolled.
      Returns:
      whether the input was processed.