I am using "Gdx.input.isTouched()" in the render method of my Screen method, to know where is touched, but when the touch is dragged in the screen, it also activates the events i want only when an actor is touched.
Is there any listener to know when an Actor is touched, but the event is not the dragged one, im doing it with sprites.
See this wiki page about scene2d in LibGDX. Specifically the part about Input handling.
Basically you have to override one or more of these methods in your Actor:
public boolean touchDown (float x, float y, int pointer) {
return false;
}
public void touchUp (float x, float y, int pointer) {
}
public void touchDragged (float x, float y, int pointer) {
}
public boolean touchMoved (float x, float y) {
return false;
}
public boolean scrolled (int amount) {
return false;
}
public boolean keyDown (int keycode) {
return false;
}
public boolean keyUp (int keycode) {
return false;
}
public boolean keyTyped (char character) {
return false;
}
in libGDX Actor
have a listener inside.
Example if you want check when a button is press, or is check, you call :
button.isPressed()
, button.isCheck()
, it return boolean.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With