您好,我正在尝试在 libgdx 游戏中构建水平滚动屏幕,但由于某种原因只能使其垂直滚动而不是水平滚动。虽然 ScrollPane
听起来很简单,但由于某种原因我并不完全理解它,但是这里的滚动片尾示例对我有一点帮助。
我有一个表格,并向其中添加了几行文本。该表格与屏幕的大小相匹配,并且还包含一个名为 scroller
的 ScrollPane
,它填充表格的大小。我猜测,由于文本行不适合屏幕,因此 scroller
,scroller
自动允许在制作人员名单示例中垂直滚动?但是,当我将文本更改为一长行文本而不是新行时,scroller
不允许我水平滚动以查看所有文本,这是为什么?文本肯定超出了scroller
宽度吗?
scrollTable = new Table(); //create table
scrollTable.add(text); //add a long line of text bigger than screen
scrollTable.row();
scrollTable.add(text2);
scrollTable.row();
scrollTable.add(text3);
scroller = new ScrollPane(scrollTable); //create the ScrollPane
Table table = new Table();
table.setFillParent(true);
table.add(scroller).fill().expand();
//scroller.setWidth(500);
//scroller.setScrollingDisabled(false, true);
stage.addActor(table);
private static final String reallyLongString =
"This is a really long string that has lots of lines and repeats itself over and over again This is a really long string that has" +
" lots of lines and repeats itself over and over again This is a really long string that has lots of lines and repeats itself over and over"+
" again This is a really long string that has lots of lines and repeats itself over and over again"+
" This is a really long string that has lots of lines and repeats itself over and over again This is a really long string that has lots"+
" of lines and repeats itself over and over again";
//This is my long string of text.
最佳答案
试试这个:
Table table = new Table();
ScrollPane scroll = new ScrollPane(table);
关于java - 为什么我的 Libgdx ScrollPane 不水平滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23809849/