public class ScalingViewport extends Viewport
Scaling
.
Scaling.fit
keeps the aspect ratio by scaling the world up to fit the screen, adding black bars (letterboxing) for the
remaining space.
Scaling.fill
keeps the aspect ratio by scaling the world up to take the whole screen (some of the world may be off
screen).
Scaling.stretch
does not keep the aspect ratio, the world is scaled to take the whole screen.
Scaling.none
keeps the aspect ratio by using a fixed size world (the world may not fill the screen or some of the world
may be off screen).
Constructor and Description |
---|
ScalingViewport(Scaling scaling,
float worldWidth,
float worldHeight)
Creates a new viewport using a new
OrthographicCamera . |
ScalingViewport(Scaling scaling,
float worldWidth,
float worldHeight,
Camera camera) |
Modifier and Type | Method and Description |
---|---|
Scaling |
getScaling() |
void |
setScaling(Scaling scaling) |
void |
update(int screenWidth,
int screenHeight,
boolean centerCamera)
Configures this viewport's screen bounds using the specified screen size and calls
Viewport.apply(boolean) . |
apply, apply, calculateScissors, getBottomGutterHeight, getCamera, getLeftGutterWidth, getPickRay, getRightGutterWidth, getRightGutterX, getScreenHeight, getScreenWidth, getScreenX, getScreenY, getTopGutterHeight, getTopGutterY, getWorldHeight, getWorldWidth, project, project, setCamera, setScreenBounds, setScreenHeight, setScreenPosition, setScreenSize, setScreenWidth, setScreenX, setScreenY, setWorldHeight, setWorldSize, setWorldWidth, toScreenCoordinates, unproject, unproject, update
public ScalingViewport(Scaling scaling, float worldWidth, float worldHeight)
OrthographicCamera
.public void update(int screenWidth, int screenHeight, boolean centerCamera)
Viewport
Viewport.apply(boolean)
. Typically called
from ApplicationListener.resize(int, int)
or Screen.resize(int, int)
.
The default implementation only calls Viewport.apply(boolean)
.
public Scaling getScaling()
public void setScaling(Scaling scaling)
Copyright © 2018. All rights reserved.