Package com.badlogic.gdx.utils.viewport
Class ExtendViewport
- java.lang.Object
-
- com.badlogic.gdx.utils.viewport.Viewport
-
- com.badlogic.gdx.utils.viewport.ExtendViewport
-
public class ExtendViewport extends Viewport
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 usingScaling.fit
, then the shorter dimension is lengthened to fill the viewport. Other scaling, such asScaling.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.
-
-
Constructor Summary
Constructors Constructor Description ExtendViewport(float minWorldWidth, float minWorldHeight)
Creates a new viewport using a newOrthographicCamera
with no maximum world size.ExtendViewport(float minWorldWidth, float minWorldHeight, float maxWorldWidth, float maxWorldHeight)
Creates a new viewport using a newOrthographicCamera
and a maximum world size.ExtendViewport(float minWorldWidth, float minWorldHeight, float maxWorldWidth, float maxWorldHeight, Camera camera)
Creates a new viewport with a maximum world size.ExtendViewport(float minWorldWidth, float minWorldHeight, Camera camera)
Creates a new viewport with no maximum world size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float
getMaxWorldHeight()
float
getMaxWorldWidth()
float
getMinWorldHeight()
float
getMinWorldWidth()
void
setMaxWorldHeight(float maxWorldHeight)
void
setMaxWorldWidth(float maxWorldWidth)
void
setMinWorldHeight(float minWorldHeight)
void
setMinWorldWidth(float minWorldWidth)
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
-
ExtendViewport
public ExtendViewport(float minWorldWidth, float minWorldHeight)
Creates a new viewport using a newOrthographicCamera
with no maximum world size.
-
ExtendViewport
public ExtendViewport(float minWorldWidth, float minWorldHeight, Camera camera)
Creates a new viewport with no maximum world size.
-
ExtendViewport
public ExtendViewport(float minWorldWidth, float minWorldHeight, float maxWorldWidth, float maxWorldHeight)
Creates a new viewport using a newOrthographicCamera
and a maximum world size.
-
ExtendViewport
public ExtendViewport(float minWorldWidth, float minWorldHeight, float maxWorldWidth, float maxWorldHeight, Camera camera)
Creates a new viewport with a maximum world size.- Parameters:
maxWorldWidth
- User 0 for no maximum width.maxWorldHeight
- User 0 for no maximum height.
-
-
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)
.
-
getMinWorldWidth
public float getMinWorldWidth()
-
setMinWorldWidth
public void setMinWorldWidth(float minWorldWidth)
-
getMinWorldHeight
public float getMinWorldHeight()
-
setMinWorldHeight
public void setMinWorldHeight(float minWorldHeight)
-
getMaxWorldWidth
public float getMaxWorldWidth()
-
setMaxWorldWidth
public void setMaxWorldWidth(float maxWorldWidth)
-
getMaxWorldHeight
public float getMaxWorldHeight()
-
setMaxWorldHeight
public void setMaxWorldHeight(float maxWorldHeight)
-
setScaling
public void setScaling(Scaling scaling)
-
-