[英]java - libgdx scrollpane doesn't scroll
我目前不知道今天的libGDX(仅适用于Android)是怎么回事...我有我的beautyfull表,带有按钮和其他一些东西,我添加了ScrollPane进行滚动(很明显),然后我将其中的所有内容添加了其他表格,并将大小值更改为屏幕中心,缩放等。现在ScrollPane无法正常工作...
buttonsTable = new Table();
buttonsTable.center().center();
// adding buttons and buttons and more buttons...
ScrollPane scroller = new ScrollPane(buttonsTable);
scroller.layout();
scrollableTable = new Table();
scrollableTable.center().center();
scrollableTable.add(scroller);
this.stage.addActor(scrollableTable);
// SIZE_WIDTH and SIZE_HEIGHT are the size of my screen
scrollableTable.pack();
scrollableTable.setTransform(true);
scrollableTable.setScale(0.5f,0.5f); // I changed the scale of the table(1/2)
scrollableTable.setPosition(SIZE_WIDTH/2 - scrollableTable.getWidth()/4, SIZE_HEIGHT/2 - scrollableTable.getHeight()/4);
// It doesn't update its height and width, so I just divide by 2 and by 2 again to go to the center
桌子在我屏幕的中央,但是现在ScrollPane已“损坏” ...
OBS:我在render()
和Gdx.input.setInputProcessor(stage);
内部调用了stage.act(Gdx.graphics.getDeltaTime())
Gdx.input.setInputProcessor(stage);
在Screen的构造函数中。
我测试了ScrollPane
滚动:
public class TestClass extends ApplicationAdapter {
Stage stage;
ExtendViewport extendViewport;
@Override
public void create() {
extendViewport =new ExtendViewport(640,400);
stage=new Stage(extendViewport);
Skin skin=new Skin(Gdx.files.internal("skin/glassy-ui.json"));
Table scrollableTable = new Table();
scrollableTable.setFillParent(true);
stage.addActor(scrollableTable);
Table table = new Table();
table.add(new TextButton("WELCOME",skin)).row();
table.add(new TextButton("TO",skin)).row();
table.add(new TextButton("LIBGDX",skin)).row();
table.add(new TextButton("GAMING",skin)).row();
table.add(new TextButton("FRAMEWORK",skin)).row();
table.pack();
table.setTransform(true); //clipping enabled
table.setOrigin(table.getWidth()/2,table.getHeight()/2);
table.setScale(.5f);
final ScrollPane scroll = new ScrollPane(table, skin);
scrollableTable.add(scroll).expand().fill();
stage.setDebugAll(true);
Gdx.input.setInputProcessor(stage);
}
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.draw();
stage.act();
}
@Override
public void dispose() {
stage.dispose();
}
@Override
public void resize(int width, int height) {
stage.getViewport().update(width,height);
stage.getCamera().position.set(320,200,0);
stage.getCamera().update();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.