libgdx如何将屏幕分割4份
问题描述:
这是我多么希望我的屏幕看起来像: 在左上边角,我需要有6 3d models
所以我会做,使用PerspectiveCamera
。右上角开玩笑需要提供一些数据,所以我会使用scene2d
来做到这一点。当3d models
将被batch.dra()
和PerspectiveCamera
淹没并且关于模型的数据将是scene2d
时,左下角需要组合。在右下角我开玩笑地需要一个scene2d
table
来显示所有连接的用户。我的问题是如何将我的屏幕分割为4,这样屏幕的每个部分都会呈现不同的效果。libgdx如何将屏幕分割4份
答
您可以尝试offsetting the viewport与setScreenX
,setScreenY
和screenBounds
。您现在需要使用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
我没有测试任何解决方案,所以我不知道它是否会为你工作。
您可以使用2行2列的表格。将它们设置为'.expand()'/'.fill()',它们应该在屏幕上平均展开。或者自己计算一下。 – Madmenyo
@Madmenyo问题是,在左上角它不是'scene2d',所以我不想在那里有一个表单元。 – Roni
尝试用'setScreenX'' setScreenY'和'screenBounds'偏移视口。 https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/viewport/Viewport.html – Madmenyo