Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static final int VIRTUAL_WIDTH = 480;
- public static final int VIRTUAL_HEIGHT = 800;
- Viewport viewport;
- SpriteBatch spriteBatch;
- ShapeRenderer shapeBatch;
- Texture img;
- @Override
- public void create()
- {
- viewport = new FitViewport(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
- spriteBatch = new SpriteBatch();
- shapeBatch = new ShapeRenderer();
- img = new Texture("test.jpg");
- }
- @Override
- public void resize(int width, int height)
- {
- viewport.update(width, height);
- }
- @Override
- public void render()
- {
- Gdx.gl.glClearColor(0, 0, 0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- shapeBatch.begin(ShapeType.Filled);
- shapeBatch.setColor(Color.GRAY);
- shapeBatch.rect(0, 0, viewport.getWorldWidth(), viewport.getWorldHeight());
- shapeBatch.end();
- spriteBatch.begin();
- spriteBatch.draw(img, 0, 0);
- spriteBatch.end();
- }
- OrthographicCamera cam = new OrthographicCamera(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
- Viewport viewport = new FitViewport(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, cam);
- shapeBatch.begin(ShapeType.Filled);
- shapeBatch.setColor(Color.GRAY);
- shapeBatch.rect(0, 0, viewport.getWorldWidth(), viewport.getWorldHeight());
- shapeBatch.end();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement