libgdx API

com.badlogic.gdx
Interface InputProcessor

All Known Implementing Classes:
GestureDetector, InputAdapter, InputMultiplexer, RemoteSender, Stage, TWL

public interface InputProcessor

An InputProcessor is used to receive input events from the keyboard and the touch screen (mouse on the desktop). For this it has to be registered with the Input.setInputProcessor(InputProcessor) method. It will be called each frame before the call to ApplicationListener.render(). The methods return a* boolean in case you want to write a multiplexing InputProcessor that has a chain of child processors that signal whether they processed the event. The InputMultiplexer offers you exactly this functionality.

Author:
badlogicgames@gmail.com

Method Summary
 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 scrolled(int amount)
          Called when the mouse wheel was scrolled.
 boolean touchDown(int x, int y, int pointer, int button)
          Called when the screen was touched or a mouse button was pressed.
 boolean touchDragged(int x, int y, int pointer)
          Called when a finger or the mouse was dragged.
 boolean touchMoved(int x, int y)
          Called when the mouse was moved without any buttons being pressed.
 boolean touchUp(int x, int y, int pointer, int button)
          Called when a finger was lifted or a mouse button was released.
 

Method Detail

keyDown

boolean keyDown(int keycode)
Called when a key was pressed

Parameters:
keycode - one of the constants in Input.Keys
Returns:
whether the input was processed

keyUp

boolean keyUp(int keycode)
Called when a key was released

Parameters:
keycode - one of the constants in Input.Keys
Returns:
whether the input was processed

keyTyped

boolean keyTyped(char character)
Called when a key was typed

Parameters:
character - The character
Returns:
whether the input was processed

touchDown

boolean touchDown(int x,
                  int y,
                  int pointer,
                  int button)
Called when the screen was touched or a mouse button was pressed. The button parameter will be Input.Buttons.LEFT on Android.

Parameters:
x - The x coordinate, origin is in the upper left corner
y - 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

boolean touchUp(int x,
                int y,
                int pointer,
                int button)
Called when a finger was lifted or a mouse button was released. The button parameter will be Input.Buttons.LEFT on Android.

Parameters:
x - The x coordinate
y - The y coordinate
pointer - the pointer for the event.
button - the button
Returns:
whether the input was processed

touchDragged

boolean touchDragged(int x,
                     int y,
                     int pointer)
Called when a finger or the mouse was dragged.

Parameters:
x - The x coordinate
y - The y coordinate
pointer - the pointer for the event.
Returns:
whether the input was processed

touchMoved

boolean touchMoved(int x,
                   int y)
Called when the mouse was moved without any buttons being pressed. Will not be called on Android.

Parameters:
x - The x coordinate
y - The y coordinate
Returns:
whether the input was processed

scrolled

boolean scrolled(int amount)
Called when the mouse wheel was scrolled. Will not be called on Android.

Parameters:
amount - the scroll amount, -1 or 1 depending on the direction the wheel was scrolled.
Returns:
whether the input was processed.

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)