我试图在屏幕底部向我的游戏添加一个较少的滑动菜单(左侧和右侧)。 我的问题是,我不能在屏幕的底部调整表,这是我的代码:JAVA-LIBGDX如何正确设置scrollPane
private void initUI() {
// inizializzazione dello stage
stage = new Stage(new ExtendViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()/4));
Skin skin = new Skin(Gdx.files.internal("ui/uiskin.json"));
Gdx.input.setInputProcessor(stage);
// inizializzazione della tabella
container = new Table();
container.setFillParent(true);
stage.addActor(container);
Table table = new Table();
table.debug();
final ScrollPane scroll = new ScrollPane(table, skin);
scroll.setFillParent(true);
InputListener stopTouchDown = new InputListener() {
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
event.stop();
return false;
}
};
table.pad(20).defaults().expandY().space(5);
for (int i = 0; i < 15; i++) {
table.row();
TextButton button = new TextButton(i + "dos", skin);
table.add(button);
button.addListener(new ClickListener() {
public void clicked (InputEvent event, float x, float y) {
System.out.println("click " + x + ", " + y);
}
});
}
container.add(scroll).expandY().fill().colspan(1);
container.row().space(10).padBottom(10);
}
render(){
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(),Gdx.graphics.getHeight()/4);
Gdx.input.setInputProcessor(stage);
stage.draw();
stage.act(Gdx.graphics.getDeltaTime());
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
这样,我可以分割屏幕分为2部分(顶部和底部),但输入不正确:要激活第一个按钮,我必须按屏幕的顶部,但底部是“设计”按钮。
我怎样才能创建一个在屏幕底部的滚动表?