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

public Class ExtendViewport

extends Viewport
Class Inheritance
Imports
com.badlogic.gdx.graphics.Camera, .OrthographicCamera, com.badlogic.gdx.math.Vector2, com.badlogic.gdx.utils.Scaling

A viewport that keeps the world aspect ratio by both scaling and extending the world. By default, the world is first scaled to fit within the viewport using Scaling#fit, then the shorter dimension is lengthened to fill the viewport. Other scaling, such as Scaling#contain, may lengthen the world in both directions. A maximum size can be specified to limit how much the world is extended and black bars (letterboxing) are used for any remaining space.
Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
private float
private float
private float
private float
private Scaling

Constructor Summary

AccessConstructor and Description
public
ExtendViewport(float minWorldWidth, float minWorldHeight)

Creates a new viewport using a new OrthographicCamera with no maximum world size.

public
ExtendViewport(float minWorldWidth, float minWorldHeight, Camera camera)

Creates a new viewport with no maximum world size.

public
ExtendViewport(float minWorldWidth, float minWorldHeight, float maxWorldWidth, float maxWorldHeight)

Creates a new viewport using a new OrthographicCamera and a maximum world size.

public
ExtendViewport(float minWorldWidth, float minWorldHeight, float
User 0 for no maximum width.
maxWorldWidth
,
float
User 0 for no maximum height.
maxWorldHeight
,
Camera camera)

Creates a new viewport with a maximum world size.

Method Summary

Modifier and TypeMethod and Description
public float
public float
public float
public float
public void
setMaxWorldHeight(float maxWorldHeight)

public void
setMaxWorldWidth(float maxWorldWidth)

public void
setMinWorldHeight(float minWorldHeight)

public void
setMinWorldWidth(float minWorldWidth)

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

maxWorldHeightback to summary
private float maxWorldHeight
maxWorldWidthback to summary
private float maxWorldWidth
minWorldHeightback to summary
private float minWorldHeight
minWorldWidthback to summary
private float minWorldWidth
scalingback to summary
private Scaling scaling

Constructor Detail

ExtendViewportback to summary
public ExtendViewport(float minWorldWidth, float minWorldHeight)

Creates a new viewport using a new OrthographicCamera with no maximum world size.

ExtendViewportback to summary
public ExtendViewport(float minWorldWidth, float minWorldHeight, Camera camera)

Creates a new viewport with no maximum world size.

ExtendViewportback to summary
public ExtendViewport(float minWorldWidth, float minWorldHeight, float maxWorldWidth, float maxWorldHeight)

Creates a new viewport using a new OrthographicCamera and a maximum world size.

See Also
ExtendViewport#ExtendViewport(float, float, float, float, Camera)
ExtendViewportback to summary
public ExtendViewport(float minWorldWidth, float minWorldHeight, float maxWorldWidth, float maxWorldHeight, Camera camera)

Creates a new viewport with a maximum world size.

Parameters
maxWorldWidth:float

User 0 for no maximum width.

maxWorldHeight:float

User 0 for no maximum height.

Method Detail

getMaxWorldHeightback to summary
public float getMaxWorldHeight()
getMaxWorldWidthback to summary
public float getMaxWorldWidth()
getMinWorldHeightback to summary
public float getMinWorldHeight()
getMinWorldWidthback to summary
public float getMinWorldWidth()
setMaxWorldHeightback to summary
public void setMaxWorldHeight(float maxWorldHeight)
setMaxWorldWidthback to summary
public void setMaxWorldWidth(float maxWorldWidth)
setMinWorldHeightback to summary
public void setMinWorldHeight(float minWorldHeight)
setMinWorldWidthback to summary
public void setMinWorldWidth(float minWorldWidth)
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).