0

LibGDX offers event listeners that we can attach to buttons. Inside listener there is a method touchUp() we can override. I come from iOS dev and in iOS there was an option touchUpInside and touchUpOutside. Namely, if the user released the finger inside the area of a button touchUpInside was called and if the user lifted finger outside the button area, touchUpOutside was called. Does libGDX offer similar functionality or is up to developers to implement that? The default libgdx touchUp does not differentiate these to scenarios.

edit: I used this code but this is extremely imprecise. I'm getting a lot of false touchUp's

public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                super.touchUp(event, x, y, pointer, button);
            if(x<button.getX()||x>(button.getX()+button.getWidth())||y<button.getY()||y>(button.getY()+button.getHeight())){
                System.out.println("retuuurn");
                return;
            }
}
potato
  • 4,479
  • 7
  • 42
  • 99

1 Answers1

0

This works:

if(x<button.getOriginX()-button.getWidth()*0.5f||x>(button.getOriginX()+button.getWidth()*0.5f)||y<button.getOriginY() - button.getHeight()*0.5f||y>(button.getOriginY()+button.getHeight()*0.5f)){
//do stuff
}
potato
  • 4,479
  • 7
  • 42
  • 99