1

「ゲーム開始」ボタンを作成するために、MenuScreen.java ファイルに次のテーブル ボタンを配置しました。

// register the button "start game"
        TextButton startGameButton = new TextButton( "Start game", getSkin() );
        startGameButton.setTouchable(Touchable.enabled);
        startGameButton.addListener( new InputListener() {

            public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
                System.out.println("down");
                Gdx.app.log( HowDrunkAreYou.LOG, "touch d" );
                return true;
        }

            public void touchUp(
                InputEvent event,
                float x,
                float y,
                int pointer,
                int button )
            {
                Gdx.app.log( HowDrunkAreYou.LOG, "touch d" );
                super.touchUp( event, x, y, pointer, button );
                game.getSoundManager().play( HowDrunkAreYouSound.CLICK );
                //game.setScreen( new StartGameScreen( game ) );
            }
        } );
        table.add( startGameButton ).size( 300, 60 ).uniform().spaceBottom( 10 );

何らかの理由で、入力ハンドラーが起動せず、Java デバッガーがメソッドに入ることはありません。私は何が欠けていますか?デスクトップとアンドロイドでテストしましたが、同じ結果でした。

logcat もコンソールも、何がエラーであるかについての情報を提供しません。

ありがとうございました!

4

1 に答える 1

2

コードで Gdx.input.setInputProcessor(stage) を使用する必要があります。このリンクが役立ちます。シュタイガートのブログスポット

今言えることは、ステージを作成し、それにテーブルを追加し、ステージを setinputprocessor() に渡す必要があるということだけです。詳細については、このリンクを参照してください。ステージとテーブルの使用について詳しく学ぶことができます

于 2013-07-24T09:31:42.017 に答える