Package com.badlogic.gdx.graphics
Class OrthographicCamera
- java.lang.Object
-
- com.badlogic.gdx.graphics.Camera
-
- com.badlogic.gdx.graphics.OrthographicCamera
-
public class OrthographicCamera extends Camera
A camera with orthographic projection.
-
-
Field Summary
Fields Modifier and Type Field Description floatzoomthe zoom of the camera-
Fields inherited from class com.badlogic.gdx.graphics.Camera
combined, direction, far, frustum, invProjectionView, near, position, projection, up, view, viewportHeight, viewportWidth
-
-
Constructor Summary
Constructors Constructor Description OrthographicCamera()OrthographicCamera(float viewportWidth, float viewportHeight)Constructs a new OrthographicCamera, using the given viewport width and height.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidrotate(float angle)Rotates the camera by the given angle around the direction vector.voidsetToOrtho(boolean yDown)Sets this camera to an orthographic projection using a viewport fitting the screen resolution, centered at (Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2), with the y-axis pointing up or down.voidsetToOrtho(boolean yDown, float viewportWidth, float viewportHeight)Sets this camera to an orthographic projection, centered at (viewportWidth/2, viewportHeight/2), with the y-axis pointing up or down.voidtranslate(float x, float y)Moves the camera by the given amount on each axis.voidtranslate(Vector2 vec)Moves the camera by the given vector.voidupdate()Recalculates the projection and view matrix of this camera and theFrustumplanes.voidupdate(boolean updateFrustum)Recalculates the projection and view matrix of this camera and theFrustumplanes ifupdateFrustumis true.-
Methods inherited from class com.badlogic.gdx.graphics.Camera
getPickRay, getPickRay, lookAt, lookAt, normalizeUp, project, project, rotate, rotate, rotate, rotate, rotateAround, transform, translate, translate, unproject, unproject
-
-
-
-
Constructor Detail
-
OrthographicCamera
public OrthographicCamera()
-
OrthographicCamera
public OrthographicCamera(float viewportWidth, float viewportHeight)Constructs a new OrthographicCamera, using the given viewport width and height. For pixel perfect 2D rendering just supply the screen size, for other unit scales (e.g. meters for box2d) proceed accordingly. The camera will show the region [-viewportWidth/2, -(viewportHeight/2-1)] - [(viewportWidth/2-1), viewportHeight/2]- Parameters:
viewportWidth- the viewport widthviewportHeight- the viewport height
-
-
Method Detail
-
update
public void update()
Description copied from class:CameraRecalculates the projection and view matrix of this camera and theFrustumplanes. Use this after you've manipulated any of the attributes of the camera.
-
update
public void update(boolean updateFrustum)
Description copied from class:CameraRecalculates the projection and view matrix of this camera and theFrustumplanes ifupdateFrustumis true. Use this after you've manipulated any of the attributes of the camera.
-
setToOrtho
public void setToOrtho(boolean yDown)
Sets this camera to an orthographic projection using a viewport fitting the screen resolution, centered at (Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2), with the y-axis pointing up or down.- Parameters:
yDown- whether y should be pointing down
-
setToOrtho
public void setToOrtho(boolean yDown, float viewportWidth, float viewportHeight)Sets this camera to an orthographic projection, centered at (viewportWidth/2, viewportHeight/2), with the y-axis pointing up or down.- Parameters:
yDown- whether y should be pointing down.viewportWidth-viewportHeight-
-
rotate
public void rotate(float angle)
Rotates the camera by the given angle around the direction vector. The direction and up vector will not be orthogonalized.- Parameters:
angle-
-
translate
public void translate(float x, float y)Moves the camera by the given amount on each axis.- Parameters:
x- the displacement on the x-axisy- the displacement on the y-axis
-
translate
public void translate(Vector2 vec)
Moves the camera by the given vector.- Parameters:
vec- the displacement vector
-
-