0

LibGDX は、ボタンにアタッチできるイベント リスナーを提供します。リスナー内には、touchUp()オーバーライドできるメソッドがあります。私はiOS devから来ました.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 に答える