com.badlogic.gdx.utils.viewport
Class ScreenViewport

java.lang.Object
  extended by com.badlogic.gdx.utils.viewport.Viewport
      extended by com.badlogic.gdx.utils.viewport.ScreenViewport

public class ScreenViewport
extends Viewport

A viewport where the world size is based on the size of the screen. By default 1 world unit == 1 screen pixel, but this ratio can be changed.

Author:
Daniel Holderbaum, Nathan Sweet

Constructor Summary
ScreenViewport()
          Creates a new viewport using a new OrthographicCamera.
ScreenViewport(Camera camera)
           
 
Method Summary
 float getUnitsPerPixel()
           
 void setUnitsPerPixel(float unitsPerPixel)
          Sets the number of pixels for each world unit.
 void update(int screenWidth, int screenHeight, boolean centerCamera)
          Updates the viewport's camera.
 
Methods inherited from class com.badlogic.gdx.utils.viewport.Viewport
calculateScissors, getBottomGutterHeight, getCamera, getLeftGutterWidth, getPickRay, getRightGutterWidth, getRightGutterX, getTopGutterHeight, getTopGutterY, getViewportHeight, getViewportWidth, getViewportX, getViewportY, getWorldHeight, getWorldWidth, project, project, setCamera, setWorldHeight, setWorldSize, setWorldWidth, toScreenCoordinates, unproject, unproject, update, update
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScreenViewport

public ScreenViewport()
Creates a new viewport using a new OrthographicCamera.


ScreenViewport

public ScreenViewport(Camera camera)
Method Detail

update

public void update(int screenWidth,
                   int screenHeight,
                   boolean centerCamera)
Description copied from class: Viewport
Updates the viewport's camera. Typically called from ApplicationListener#resize(int, int) or Screen#resize(int, int).

The default implementation calls GL20.glViewport(int, int, int, int) and configures the camera viewport size.

Overrides:
update in class Viewport
centerCamera - If true, the camera position is set to the center of the world.

getUnitsPerPixel

public float getUnitsPerPixel()

setUnitsPerPixel

public void setUnitsPerPixel(float unitsPerPixel)
Sets the number of pixels for each world unit. Eg, a scale of 2.5 means there are 2.5 world units for every 1 screen pixel. Default is 1.



Copyright © 2014. All Rights Reserved.