Tutorial by Examples

To support multiple resolutions and aspect ratios Libgdx uses the so called Viewports. There are a few types of Viewports which use different strategies to handle multiple resolutions and aspect ratios. A Viewport uses a Camera under the hood and manages it's viewportHeight and viewportWidth. You ...
There are a couple of builtin viewports, that each do different things. Here is a list of the names, and their descriptions: Viewport NameDescriptionStretchViewportWill stretch the screen. No black bars, but aspect ratio might be off.FitViewportWill maximize it's size based on the aspect ratio. Cou...
You can make your very own custom viewport. It may have black bars, and it may or may not keep it's aspect ratio, depending on how you program it. A custom viewport would look something like this: public class Tutorial extends Viewport. You would need to override update(width, height), but that's it...
The StretchViewport is a Viewporttype, which supports a virtual screen size. This allowes you to define a fixed (resolution independent) width and height. The StretchViewport, as the name suggests, stretches the virtual screen, if the virtual aspect ratio does not match the real aspect ratio. The ...
FitViewports are viewports that always maintain the aspect ratio. It does this by creating black bars on the edges where there is space left. This is one of the most commonly used viewports. Usage: private Viewport viewport; private Camera camera; public void create() { camera = new Ortho...

Page 1 of 1