0

LibGDX 提供了我们可以附加到按钮的事件监听器。在侦听器内部有一个touchUp()我们可以覆盖的方法。我来自 iOS 开发人员,在 iOS 中有一个选项touchUpInsidetouchUpOutside. 即,如果用户在按钮区域内松开手指,touchUpInside则调用,如果用户在按钮区域外抬起手指,touchUpOutside则调用。libGDX 是否提供类似的功能,还是由开发人员来实现?默认的 libgdxtouchUp不会将这些与场景区分开来。

编辑:我使用了这段代码,但这非常不精确。我得到了很多错误的修饰

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;
            }
}
4

1 回答 1

0

这有效:

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
}
于 2015-12-25T19:21:00.647 回答