我有多个实现 Screen
的类。
我想要在主菜单屏幕中设置portrait
,然后在游戏屏幕中设置landscape
。有没有办法动态改变orientation
?
我原以为可以启动另一个Activity
,并让游戏屏幕扩展Game
。新的Activity
将初始化Play Screen。但显然不能调用startActivity
或类似的方法,因为LibGDX
是跨平台的。
我使用Gdx.graphics.getWidth()
和Gdx.graphics.getHeight()
来对齐Sprites
和Actors
,使其在不同设备上看起来“正确”。
我还尝试交换Gdx.graphics.getWidth()
和Gdx.graphics.getHeight()
,但无法正确获取精灵和演员的位置。
此外,在我的清单中,我将orientation="landscape"
。
下面是一些图片,可能更容易理解:
这是我的landscape
模式下的主菜单:
这是我的portrait
模式下的主菜单:
Actors
和Sprites
的位置和大小都基于Gdx.graphics.getWidth()
和Gdx.graphics.getHeight()
。两个图像之间唯一变化的是我的清单中的orientation="landscape"
和orientation="portrait"
。
现在我希望我的主菜单是portrait
,但Play Screen,即游戏屏幕应该是landscape
。
最初,我开始工作于Play Screen,并且基于orientation="landscape"
设置了大小和位置,现在我正在处理主菜单,它基于orientation="portrait"
。因此,我希望动态更改方向。
Gdx.graphics.getWidth()
和Gdx.graphics.getHeight()
来获取根据屏幕方向正确的宽度和高度。 - user959631orientation
。感谢您的帮助。 - user959631