2014-05-22 1 views
1

안녕하세요, 내 libgdx 게임에서 가로 스크롤 화면을 만들려고하지만 단지 가로로 스크롤하는 대신 어떤 이유로 가로로 얻을 수 있습니다. ScrollPane이 단순하게 들리 긴하지만 나는 어떤 이유로 그것을 완전히 이해하지 못한다. 그러나 여기에 대한 스크롤링 예제는 나에게 조금 도움이되었다.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. 
+0

내가 ... ScrollPane'가 가로 방향으로 만 작동합니다'나는 그것이 수평으로 작동하도록 할 방법 –

+0

을 믿습니다. 그것은 세로 또는 가로로 작동하며 아이템/오브젝트가 컨테이너 경계를 벗어나면 자동으로 수행됩니다. – user2002077

+0

나는 그것이 단지 하나라고 생각한다. 두 개를 사용 해보 라. –

답변

0

이 시도 :

Table table = new Table(); 
ScrollPane scroll = new ScrollPane(table); 
+5

좀 더 자세히 설명해야합니다. 그것은 무엇을하고 왜 작동합니까? – Jens

+0

http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.html – Alex

관련 문제