2017-07-07 88 views
0

这是我多么希望我的屏幕看起来像: main screen 在左上边角,我需要有6 3d models所以我会做,使用PerspectiveCamera。右上角开玩笑需要提供一些数据,所以我会使用scene2d来做到这一点。当3d models将被batch.dra()PerspectiveCamera淹没并且关于模型的数据将是scene2d时,左下角需要组合。在右下角我开玩笑地需要一个scene2dtable来显示所有连接的用户。我的问题是如何将我的屏幕分割为4,这样屏幕的每个部分都会呈现不同的效果。libgdx如何将屏幕分割4份

+0

您可以使用2行2列的表格。将它们设置为'.expand()'/'.fill()',它们应该在屏幕上平均展开。或者自己计算一下。 – Madmenyo

+0

@Madmenyo问题是,在左上角它不是'scene2d',所以我不想在那里有一个表单元。 – Roni

+0

尝试用'setScreenX'' setScreenY'和'screenBounds'偏移视口。 https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/viewport/Viewport.html – Madmenyo

回答

1

您可以尝试offsetting the viewportsetScreenX,setScreenYscreenBounds。您现在需要使用2个视口。

否则可以直接改变视口。 Gdx.gl.glViewport(0,Gdx.graphics.getHeight()/2,Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2);应该在上角画出一切。在更新它将看起来像这样:

`Gdx.gl.glViewport(0,Gdx.graphics.getHeight()/2,Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2); 
//Draw upper right window stuff 

Gdx.gl.glViewport(0,0, Gdx.graphics.getWidth(),Gdx.graphics.getHeight()); 
//Draw your stage and just leave the upper right window/table cell transparent 

我没有测试任何解决方案,所以我不知道它是否会为你工作。

+0

我也看到了这个解决方案。但问题是我目前正在使用合适的视图端口,并且这种解决方案是不能节省比例。事情开始拉伸。 – Roni

+0

显然,您需要使用正确的宽高比设置宽度和高度。我不确定'FitViewport'和第二种方法的行为,但也许你可以尝试'CustomViewport'。第二种方法应该将所有内容缩小到屏幕的1/4并将其推到左上角。 – Madmenyo