How to detect when a touch has been released?
android, libgdx, touch, touch-event
Solution
According to the libgdx wiki, you must implement the `InputProcessor` interface. In the interface there is a function called `touchUp` that should be called when touches are released.
You can read all about touch input with libgdx here: http://code.google.com/p/libgdx/wiki/InputEvent
There is a fairly simple example on the wiki. Here is the implemented interface:
public class MyInputProcessor implements InputProcessor {
@Override
public boolean keyDown (int keycode) {
return false;
}
@Override
public boolean keyUp (int keycode) {
return false;
}
@Override
public boolean keyTyped (char character) {
return false;
}
@Override
public boolean touchDown (int x, int y, int pointer, int button) {
return false;
}
@Override
public boolean touchUp (int x, int y, int pointer, int button) {
return false; /* This should be what you're looking for. */
}
@Override
public boolean touchDragged (int x, int y, int pointer) {
return false;
}
@Override
public boolean touchMoved (int x, int y) {
return false;
}
@Override
public boolean scrolled (int amount) {
return false;
}
}
How to set your class as a listener:
MyInputProcessor inputProcessor = new MyInputProcessor();
Gdx.input.setInputProcessor(inputProcessor);
Problem
I'm trying to find a way to detect when a touch point has been released using `gdx.input` as part of libgdx. I know about the Android way of determining when a touch point is released as described here but I'm looking for a libgdx specific way of doing this. How can I detect when a touch has been released? I could not find a method that does this in `gdx.input`.