Advertisement
Guest User

Untitled

a guest
May 18th, 2015
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. package com.Test.game;
  2.  
  3. import com.badlogic.gdx.Game;
  4. import com.badlogic.gdx.Gdx;
  5. import com.badlogic.gdx.graphics.GL20;
  6. import com.badlogic.gdx.graphics.OrthographicCamera;
  7. import com.badlogic.gdx.graphics.g2d.TextureAtlas;
  8. import com.badlogic.gdx.scenes.scene2d.Stage;
  9. import com.badlogic.gdx.scenes.scene2d.ui.Image;
  10. import com.badlogic.gdx.utils.viewport.FillViewport;
  11. import com.badlogic.gdx.utils.viewport.Viewport;
  12.  
  13. public class Main extends Game {
  14.     OrthographicCamera cam;
  15.     Viewport viewport;
  16.     Stage stage;
  17.  
  18.     TextureAtlas atlas;
  19.     Image Logo;
  20.    
  21.     @Override
  22.     public void create () {
  23.         cam = new OrthographicCamera(800, 600);
  24.         viewport = new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), cam);
  25.         viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
  26.         stage = new Stage(viewport);
  27.  
  28.         atlas = new TextureAtlas("LoadingScreen.pack");
  29.         Logo = new Image(atlas.findRegion("VeslaLogo"));
  30.         stage.addActor(Logo);
  31.     }
  32.  
  33.     @Override
  34.     public void resize(int Width, int Height) {
  35.         viewport.update(Width, Height, true);
  36.  
  37.         Logo.setSize(700, 500);
  38.         Logo.setX(Width / 2 - Logo.getWidth() / 2);
  39.         Logo.setY(Height / 2 - Logo.getHeight() / 2);
  40.         Logo.setOrigin(Logo.getWidth() / 2, Logo.getHeight() / 2);
  41.     }
  42.  
  43.     @Override
  44.     public void render () {
  45.         Gdx.gl.glClearColor(1, 0, 0, 1);
  46.         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  47.  
  48.         stage.act();
  49.         stage.draw();
  50.     }
  51.  
  52.     @Override
  53.     public void dispose() {
  54.         atlas.dispose();
  55.         stage.dispose();
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement