0
私はLibGDXに少し新しく、一度にどれだけ多くのボタンをダウン状態にすることができるのか不思議に思っていました。私がこれらのボタンで達成したいと思うのはこれです:私の指が1つに触れると、それは押され、一度に1つしか押せなくなり、そして私の指のうちの1つがそれを押すボタンにあり、もう1つのボタンを押すと、最初に押されたものが元の状態に戻り、もう一度押さえる唯一の方法は、私が指を離してもう一度押すことです。LibGDX ButtonGroupコントロールダウンできるボタンの数
とにかく、ここに私のコードです。どんな助けでも感謝します、ありがとう。
public MenuStateTest(GameStateManager gsm) {
super(gsm);
cam.setToOrtho(false, MyGame.WIDTH, MyGame.HEIGHT);
fitViewport = new FitViewport(MyGame.WIDTH, MyGame.HEIGHT);
stage = new Stage(fitViewport);
Gdx.input.setInputProcessor(stage);
font = new BitmapFont();
skin = new Skin();
buttonAtlas = new TextureAtlas("buttonTest.pack");
skin.addRegions(buttonAtlas);
textButtonStyle = new TextButton.TextButtonStyle();
textButtonStyle.font = font;
textButtonStyle.up = skin.getDrawable("1BBlock");
textButtonStyle.down = skin.getDrawable("T1BBlock");
button = new TextButton("", textButtonStyle);
stage.addActor(button);
button.setPosition(20, 200);
button.getStyle().checked = button.getStyle().down;
button2Atlas = new TextureAtlas("Button2Test.pack");
skin.addRegions(button2Atlas);
textButtonStyle = new TextButton.TextButtonStyle();
textButtonStyle.font = font;
textButtonStyle.up = skin.getDrawable("2BBlock");
textButtonStyle.down = skin.getDrawable("T2BBlock");
button2 = new TextButton("", textButtonStyle);
stage.addActor(button2);
button2.setPosition(175, 200);
button2.getStyle().checked = button2.getStyle().down;
button3Atlas = new TextureAtlas("Button3Test.pack");
skin.addRegions(button3Atlas);
textButtonStyle = new TextButton.TextButtonStyle();
textButtonStyle.font = font;
textButtonStyle.up = skin.getDrawable("3BBlock");
textButtonStyle.down = skin.getDrawable("T3BBlock");
button3 = new TextButton("", textButtonStyle);
stage.addActor(button3);
button3.setPosition(330, 200);
button3.getStyle().checked = button3.getStyle().down;
ButtonGroup buttons = new ButtonGroup(button1, button2, button3);
buttons.setMaxCheckCount(1);
}
@Override
protected void handleInput() {
}
@Override
protected void update(float dt) {
stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
はいますが、ここでの問題は、ボタンが唯一の私は私の指を手放す一度活性化させるということですが、私はすぐに私はボタンにタッチすると、彼らがアクティブになるように、それを作る方法を把握しようとしています。 – user2965071
私はあなたのゲームコントロールをセットアップする簡単な方法を考え出すことをお勧めしますが、私はあなたに何をすべきかを伝えるつもりはありません。これはもちろん個人的な意見ですが、私がこのようなコントロールを使ってゲームをしているのかどうかは分かりますが、それは私の邪魔になるでしょう:-)。最後の注意として、あなたがこのようにすることを主張すれば、手動でハンドル入力イベントをオーバーライドし、if-then-elsesの束を持ち、誰かがそれを示唆するかもしれませんが、それは私ではありません。図書館がどのようにそれをうまく利用できるようになっているかを知ることは、正しいことではありません。がんばろう – WonderfulWorld