Advertisement

libgdx screen issues

Started by June 01, 2015 12:42 AM
0 comments, last by Serapth 9 years, 7 months ago

I'm trying to make a jumper type game for android and I am having some trouble getting the screen to function correctly. I have a camera and a viewport but I dont think I'm using either of them properly.


camera = new OrthographicCamera();
        viewport = new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), camera); 
        camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

It's my understaing that Gdx.graphics.getWidth() gets the width of the screen resolution no matter what device it is on?


camera.update();
        game.batch.setProjectionMatrix(camera.combined);
        game.batch.begin();

This is in the draw method. When I draw my background at 0, 0 the picture starts doesnt cover all the screen and you can still see the background color.

Read this, I am almost certain it addresses the problem you are encountering. The next part covers viewports as well. In a nutshell, you need to position your camera.

This topic is closed to new replies.

Advertisement