Advertisement
Guest User

AbstractScreen.java

a guest
Apr 30th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.22 KB | None | 0 0
  1. package org.sandholm.max.airplane;
  2.  
  3. import com.badlogic.gdx.Gdx;
  4. import com.badlogic.gdx.Screen;
  5. import com.badlogic.gdx.files.FileHandle;
  6. import com.badlogic.gdx.graphics.g2d.BitmapFont;
  7. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  8. import com.badlogic.gdx.scenes.scene2d.Stage;
  9. import com.badlogic.gdx.scenes.scene2d.ui.Skin;
  10. import com.badlogic.gdx.scenes.scene2d.ui.Table;
  11.  
  12. public abstract class AbstractScreen implements Screen {
  13.    
  14.     protected final AirplaneGame game;
  15.     protected final BitmapFont font;
  16.     protected final SpriteBatch batch;
  17.     protected final Stage stage;
  18.     private Table table;
  19.     private Skin skin;
  20.    
  21.     public AbstractScreen(AirplaneGame game ) {
  22.             this.game = game;
  23.             this.font = new BitmapFont();
  24.             this.batch = new SpriteBatch();
  25.             this.stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true, batch);
  26.             //this.stage
  27.     }
  28.    
  29.     @Override
  30.     public void render(float delta) {
  31.         //Gdx.gl.glViewport((int) viewport.x, (int) viewport.y, (int) viewport.width, (int) viewport.height);
  32.        
  33.         //Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
  34.         //Gdx.gl.glClear( GL20.GL_COLOR_BUFFER_BIT );
  35.        
  36.         stage.act( delta );
  37.         stage.draw();
  38.  
  39.     }
  40.    
  41.     protected Skin getSkin()
  42.     {
  43.         if( skin == null ) {
  44.             FileHandle skinFile = Gdx.files.internal( "uiskin/uiskin.json" );
  45.             skin = new Skin( skinFile );
  46.         }
  47.         return skin;
  48.     }
  49.    
  50.     protected Table getTable()
  51.     {
  52.         if( table == null ) {
  53.             table = new Table(getSkin());
  54.             table.setFillParent( true );
  55.             stage.addActor( table );
  56.         }
  57.         return table;
  58.     }
  59.    
  60.     @Override
  61.     public void resize(int width, int height) {
  62.     }
  63.  
  64.     @Override
  65.     public void show() {
  66.         // TODO Auto-generated method stub
  67.  
  68.     }
  69.  
  70.     @Override
  71.     public void hide() {
  72.         // TODO Auto-generated method stub
  73.  
  74.     }
  75.  
  76.     @Override
  77.     public void pause() {
  78.         // TODO Auto-generated method stub
  79.  
  80.     }
  81.  
  82.     @Override
  83.     public void resume() {
  84.         // TODO Auto-generated method stub
  85.  
  86.     }
  87.  
  88.     @Override
  89.     public void dispose() {
  90.         stage.dispose();
  91.         font.dispose();
  92.         batch.dispose();
  93.     }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement