Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. public class GameCamera {
  2.  
  3. /*
  4. Camera and Viewport that operate the main game-screen.
  5. Uses a StretchViewport to stretch / fit the screen to the
  6. VIRTUAL_WIDTH and VIRTUAL_HEIGHT.
  7. */
  8. public OrthographicCamera camera;
  9. private StretchViewport viewport;
  10.  
  11. //virtual width & height
  12. public final int VIRTUAL_WIDTH = 750;
  13. public final int VIRTUAL_HEIGHT = 1334;
  14.  
  15.  
  16. /*
  17. Constructor.
  18. */
  19. public GameCamera () {
  20. camera = new OrthographicCamera();
  21. viewport = new StretchViewport(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, camera);
  22. viewport.apply();
  23. camera.position.set(VIRTUAL_WIDTH / 2, VIRTUAL_HEIGHT / 2, 0f);
  24. camera.update();
  25. }
  26.  
  27. public void updateSize (int width, int height) {
  28. viewport.update(width, height);
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement