Package com.badlogic.gdx.utils.viewport
Class ScalingViewport
- java.lang.Object
-
- com.badlogic.gdx.utils.viewport.Viewport
-
- com.badlogic.gdx.utils.viewport.ScalingViewport
-
- Direct Known Subclasses:
FillViewport
,FitViewport
,StretchViewport
public class ScalingViewport extends Viewport
A viewport that scales the world usingScaling
.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 Summary
Constructors Constructor Description ScalingViewport(Scaling scaling, float worldWidth, float worldHeight)
Creates a new viewport using a newOrthographicCamera
.ScalingViewport(Scaling scaling, float worldWidth, float worldHeight, Camera camera)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 callsViewport.apply(boolean)
.-
Methods inherited from class com.badlogic.gdx.utils.viewport.Viewport
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
-
-
-
-
Constructor Detail
-
ScalingViewport
public ScalingViewport(Scaling scaling, float worldWidth, float worldHeight)
Creates a new viewport using a newOrthographicCamera
.
-
-
Method Detail
-
update
public void update(int screenWidth, int screenHeight, boolean centerCamera)
Description copied from class:Viewport
Configures this viewport's screen bounds using the specified screen size and callsViewport.apply(boolean)
. Typically called fromApplicationListener.resize(int, int)
orScreen.resize(int, int)
.The default implementation only calls
Viewport.apply(boolean)
.
-
getScaling
public Scaling getScaling()
-
setScaling
public void setScaling(Scaling scaling)
-
-