Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. public static final int VIRTUAL_WIDTH = 480;
  2. public static final int VIRTUAL_HEIGHT = 800;
  3. Viewport viewport;
  4. SpriteBatch spriteBatch;
  5. ShapeRenderer shapeBatch;
  6. Texture img;
  7.  
  8. @Override
  9. public void create()
  10. {
  11. viewport = new FitViewport(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
  12. spriteBatch = new SpriteBatch();
  13. shapeBatch = new ShapeRenderer();
  14. img = new Texture("test.jpg");
  15. }
  16.  
  17. @Override
  18. public void resize(int width, int height)
  19. {
  20. viewport.update(width, height);
  21. }
  22.  
  23. @Override
  24. public void render()
  25. {
  26. Gdx.gl.glClearColor(0, 0, 0, 1);
  27. Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  28.  
  29. shapeBatch.begin(ShapeType.Filled);
  30. shapeBatch.setColor(Color.GRAY);
  31. shapeBatch.rect(0, 0, viewport.getWorldWidth(), viewport.getWorldHeight());
  32. shapeBatch.end();
  33.  
  34. spriteBatch.begin();
  35. spriteBatch.draw(img, 0, 0);
  36. spriteBatch.end();
  37. }
  38.  
  39. OrthographicCamera cam = new OrthographicCamera(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
  40.  
  41. Viewport viewport = new FitViewport(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, cam);
  42.  
  43. shapeBatch.begin(ShapeType.Filled);
  44. shapeBatch.setColor(Color.GRAY);
  45. shapeBatch.rect(0, 0, viewport.getWorldWidth(), viewport.getWorldHeight());
  46. shapeBatch.end();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement