Class OrthographicCamera


  • public class OrthographicCamera
    extends Camera
    A camera with orthographic projection.
    • Field Detail

      • zoom

        public float zoom
        the zoom of the camera
    • 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 width
        viewportHeight - the viewport height
    • Method Detail

      • update

        public void update()
        Description copied from class: Camera
        Recalculates the projection and view matrix of this camera and the Frustum planes. Use this after you've manipulated any of the attributes of the camera.
        Specified by:
        update in class Camera
      • update

        public void update​(boolean updateFrustum)
        Description copied from class: Camera
        Recalculates the projection and view matrix of this camera and the Frustum planes if updateFrustum is true. Use this after you've manipulated any of the attributes of the camera.
        Specified by:
        update in class 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-axis
        y - the displacement on the y-axis
      • translate

        public void translate​(Vector2 vec)
        Moves the camera by the given vector.
        Parameters:
        vec - the displacement vector