Libgdx:修补事件意外发生



我正在使用Libgdx编写一个简单的android游戏。

我为我的Actor设置了这样的边界:

setBounds(posX, posY, width, heigh);

我相信所有的触摸事件只会发生在那个区域。但是touchUp事件的行为异常,当我触摸到actor的边界内,然后拖出该边界时,touchUp事件仍然发生。

public void touchUp(InputEvent event, float x, float y,
                int pointer, int button) {
            //Touch up event still occur out of actor's boundary
        }

我在这里做错了什么吗?

提前感谢,对不起我的英语:)

我假设你说的是InputListener的touchUp方法。根据文档,当手指触摸到任何时,就会调用这个函数!所以,不,你没有做错任何事:它是这样设计的。

public void touchUp(InputEvent event,
                    float x,
                    float y,
                    int pointer,
                    int button)

当鼠标按钮或手指触摸到任何地方时调用,但是只有当touchDown先前为鼠标按钮或返回true时联系。touchUp事件总是被处理。

最新更新