Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package atotb;
- import com.badlogic.gdx.Game;
- import com.badlogic.gdx.Screen;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- public class TwoBrothersGame extends Game {
- SpriteBatch batch;
- Texture img;
- Screen gameScreen;
- @Override
- public void create () {
- batch = new SpriteBatch();
- img = new Texture("badlogic.jpg");
- gameScreen = new GameScreen(this);
- setScreen(gameScreen);
- }
- @Override
- public void dispose() {
- batch.dispose();
- img.dispose();
- gameScreen.dispose();
- }
- }
- ------------------------------------------------------------------------------------------------------------------------
- package atotb;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.Screen;
- import com.badlogic.gdx.graphics.GL20;
- import com.badlogic.gdx.graphics.OrthographicCamera;
- import com.badlogic.gdx.utils.viewport.ScreenViewport;
- import com.badlogic.gdx.utils.viewport.Viewport;
- class GameScreen implements Screen {
- TwoBrothersGame game;
- OrthographicCamera camera;
- Viewport viewport;
- public GameScreen(TwoBrothersGame game) {
- this.game = game;
- camera = new OrthographicCamera();
- viewport = new ScreenViewport(camera);
- }
- @Override
- public void render(float dt) {
- camera.update();
- Gdx.gl.glClearColor(1, 0, 0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- game.batch.begin();
- game.batch.draw(game.img, 0, 0);
- game.batch.end();
- }
- @Override
- public void resize(int width, int height) {
- viewport.update(width, height);
- }
- @Override
- public void show() {
- }
- @Override
- public void hide() {
- }
- @Override
- public void pause() {
- }
- @Override
- public void resume() {
- }
- @Override
- public void dispose() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment