Ich fragte mich, ob es eine Möglichkeit gab, Android-Spiele in libgdx zu machen, so dass sie alle die gleiche Auflösung von 480x800 teilen. Die Verwendung von Gdx.graphics.setDisplayMode (480, 800, true) scheint nichts zu ändern. Das Erstellen einer OrthographicCamera von 480 mal 800 macht es so, dass das Spiel 480 mal 800 ist, zoomt aber nicht in den Vollbildmodus und nimmt den gesamten Bildschirm auf, wie ich es erwartet hätte. Als ich es auf meinem Telefon ausprobierte, nutzte das Telefon nur Leerraum, um den Rest des Bildschirms während des Spiels in 480x800 Auflösung zu füllen. Hier ist der Code, den ich verwende.Fullscreen-Auflösung auf Android für libgdx Spiele
public class GameScreen implements Screen {
private Game game;
private OrthographicCamera guiCam;
private SpriteBatch batch;
private Texture texture;
private Rectangle glViewport;
public GameScreen (Game game)
{
this.game = game;
guiCam = new OrthographicCamera(GAME_WIDTH, GAME_HEIGHT);
guiCam.position.set(GAME_WIDTH/2, GAME_HEIGHT/2, 0);
batch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("data/c2.png"));
glViewport = new Rectangle(0, 0, GAME_WIDTH, GAME_HEIGHT);
}
@Override
public void render(float delta) {
if (Gdx.input.justTouched()) {
texture = new Texture(Gdx.files.internal("data/c1.png"));
}
GL10 gl = Gdx.graphics.getGL10();
gl.glClearColor(1, 0, 0, 1);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
gl.glViewport((int) glViewport.x, (int) glViewport.y,
(int) glViewport.width, (int) glViewport.height);
guiCam.update();
guiCam.apply(gl);
batch.setProjectionMatrix(guiCam.combined);
batch.begin();
batch.draw(texture, 0, 0, 0, 0, 142, 192);
batch.end();
}
private static final int GAME_WIDTH = 480;
private static final int GAME_HEIGHT = 800;
}
Vielen Dank im Voraus.
Vielen Dank, das war wirklich hilfreich. – MasterBirdy