Question

I'm trying to make an app using libgdx. When I first launch it on my desktop, my map print well. But if I resize the window, the map is no longer completely in the screen. But if I change the size on the beginning, the map print well. So there might be an issue with my resizing function.

In my GameScreen class I've got :

public void resize(int width, int height)
    {
        renderer.setSize(width, height);
    }

And my renderer got this :

public void setSize (int w, int h) 
    {
        ppuX = (float)w / (float)world.getWidth();
        ppuY = (float)h / (float)world.getHeight();
    }

For example, if I reduce my window, the map is too small for the window. If I extend it, the map doesn't in it.

Was it helpful?

Solution

If you have a fixed viewport, which is the case most of the time. You don't need to do anything in your resize method. The camera will fill the window to draw everything even if you resize it at runtime.

I, myself, never put anything on resize.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top