Guest User

Untitled

a guest
May 19th, 2014
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import com.badlogic.gdx.Game;
  2. import com.badlogic.gdx.Gdx;
  3. import com.badlogic.gdx.graphics.GL20;
  4. import com.badlogic.gdx.graphics.OrthographicCamera;
  5. import com.badlogic.gdx.maps.tiled.TiledMap;
  6. import com.badlogic.gdx.maps.tiled.TmxMapLoader;
  7. import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
  8.  
  9. public class GameScreen extends EscapeOrcsScreen {
  10.    
  11.     private TiledMap map;
  12.     private OrthogonalTiledMapRenderer mapRenderer;
  13.     private OrthographicCamera camera;
  14.    
  15.     public GameScreen(Game g) {
  16.         super(g);
  17.     }
  18.  
  19.     @Override
  20.     public void show(){
  21.         map = new TmxMapLoader().load(Gdx.files.internal("maps/map.tmx").toString());
  22.         mapRenderer = new OrthogonalTiledMapRenderer(map);
  23.    
  24.         camera = new OrthographicCamera();
  25.         camera.setToOrtho(true);
  26.     }
  27.    
  28.     @Override
  29.     public void resize(int width, int height){
  30.         camera.viewportHeight = height/3;
  31.         camera.viewportWidth = width/3;
  32.         camera.position.set(camera.viewportWidth/2, camera.viewportHeight/2,0);
  33.         camera.update();
  34.     }
  35.    
  36.     @Override
  37.     public void render(float delta){
  38.         Gdx.gl.glClearColor(0.8f, 0.8f, 0.8f, 1);
  39.         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  40.        
  41.         mapRenderer.setView(camera);
  42.         mapRenderer.render();
  43.     }
  44.    
  45.     @Override
  46.     public void hide(){
  47.         dispose();
  48.     }
  49.    
  50.     @Override
  51.     public void dispose(){
  52.         map.dispose();
  53.         mapRenderer.dispose();
  54.     }
  55. }
RAW Paste Data