如何获得使用LIBGDX And​​roid设备的屏幕分辨率?如何获得、屏幕分辨率、设备、And

2023-09-06 02:16:32 作者:执迷不悟 qI

我的工作安卓游戏开发和我是新的吧。 我想开发一个游戏,屏幕分辨率免费。这将是足以让我,如果我了解了如何捕捉使用libgdx库Android设备的屏幕分辨率。 经过一番google搜索我阅读不同网站上的以下code,但它不是libgdx。

I am working android game development and I am new in it. I want to develop a game which screen resolution free. It will be enough for me if i get to know that how to catch screen resolution of an android device using libgdx library. After some googling i read the following code on different sites, but it is not for libgdx.

DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
height = displaymetrics.heightPixels;
width = displaymetrics.widthPixels;

除了这一点,我在下面的网站上使用了OrthographicCamera级解决的问题,对我也没有工作,也给使用的技术。

Except this i also used technique given on the following website that used "OrthographicCamera" class for solving the problem, and didn't work for me either.

http://www.java-gaming.org/index.php?topic=25685.0

PLZ帮我,我怎么能得到屏幕分辨率,任何方式来调整屏幕的分辨率为我的比赛。

plz help me out that how can i get the screen resolution or any way to adjust screen resolution for my game.

推荐答案

虽然有一些答案在这里我的问题,但是这到底是什么工作对我来说:

Though there are some answers here on my question, but this is what exactly worked for me:

Gdx.app.graphics.getWidth(); 
Gdx.app.graphics.getHeight();