APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.utils.viewport

public Class ScalingViewport

extends Viewport
Class Inheritance
Known Direct Subclasses
com.badlogic.gdx.utils.viewport.StretchViewport, com.badlogic.gdx.utils.viewport.FillViewport, com.badlogic.gdx.utils.viewport.FitViewport
Imports
com.badlogic.gdx.graphics.Camera, .OrthographicCamera, com.badlogic.gdx.math.Vector2, com.badlogic.gdx.utils.Scaling

A viewport that scales the world using 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).

Authors
Daniel Holderbaum, Nathan Sweet

Field Summary

Modifier and TypeField and Description
private Scaling

Constructor Summary

AccessConstructor and Description
public
ScalingViewport(Scaling scaling, float worldWidth, float worldHeight)

Creates a new viewport using a new OrthographicCamera.

public
ScalingViewport(Scaling scaling, float worldWidth, float worldHeight, Camera camera)

Method Summary

Modifier and TypeMethod and Description
public Scaling
public void
public void
update(int screenWidth, int screenHeight, boolean centerCamera)

Overrides com.badlogic.gdx.utils.viewport.Viewport.update.

Configures this viewport's screen bounds using the specified screen size and calls apply(boolean).

Inherited from com.badlogic.gdx.utils.viewport.Viewport:
applyapplycalculateScissorsgetBottomGutterHeightgetCameragetLeftGutterWidthgetPickRaygetRightGutterWidthgetRightGutterXgetScreenHeightgetScreenWidthgetScreenXgetScreenYgetTopGutterHeightgetTopGutterYgetWorldHeightgetWorldWidthprojectprojectsetCamerasetScreenBoundssetScreenHeightsetScreenPositionsetScreenSizesetScreenWidthsetScreenXsetScreenYsetWorldHeightsetWorldSizesetWorldWidthtoScreenCoordinatesunprojectunprojectupdate

Field Detail

scalingback to summary
private Scaling scaling

Constructor Detail

ScalingViewportback to summary
public ScalingViewport(Scaling scaling, float worldWidth, float worldHeight)

Creates a new viewport using a new OrthographicCamera.

ScalingViewportback to summary
public ScalingViewport(Scaling scaling, float worldWidth, float worldHeight, Camera camera)

Method Detail

getScalingback to summary
public Scaling getScaling()
setScalingback to summary
public void setScaling(Scaling scaling)
updateback to summary
public void update(int screenWidth, int screenHeight, boolean centerCamera)

Overrides com.badlogic.gdx.utils.viewport.Viewport.update.

Doc from com.badlogic.gdx.utils.viewport.Viewport.update.

Configures this viewport's screen bounds using the specified screen size and calls apply(boolean). Typically called from ApplicationListener#resize(int, int) or Screen#resize(int, int).

The default implementation only calls apply(boolean).