【发布时间】:2015-12-25 18:43:09
【问题描述】:
LibGDX 提供了我们可以附加到按钮的事件监听器。在侦听器内部有一个方法touchUp() 我们可以覆盖。我来自 iOS 开发人员,在 iOS 中有一个选项 touchUpInside 和 touchUpOutside。即,如果用户在按钮区域内松开手指touchUpInside,则调用;如果用户在按钮区域外抬起手指,则调用touchUpOutside。 libGDX 是否提供类似的功能,还是由开发人员来实现?默认的 libgdx touchUp 不区分这些场景。
编辑:我使用了这段代码,但这非常不精确。我得到了很多错误的修饰
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;
}
}
【问题讨论】:
-
是的,你需要自己实现。