LibGDX 提供了我们可以附加到按钮的事件监听器。在侦听器内部有一个touchUp()
我们可以覆盖的方法。我来自 iOS 开发人员,在 iOS 中有一个选项touchUpInside
和touchUpOutside
. 即,如果用户在按钮区域内松开手指,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;
}
}