문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top