SHARE
TWEET

Untitled

a guest Sep 13th, 2014 176 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class StoneScreen implements Screen {
  2.                
  3.         OrthographicCamera camera;
  4.         final TombStone game;
  5.        
  6.         //Textures and art.
  7.         public Texture background, sdStone, arrowBack;
  8.         public Sprite backgrounds;
  9.        
  10.         //TextField´s stuff
  11.         private Stage stage;
  12.         private Skin skin;
  13.         ImageButton btnArrow;
  14.        
  15.        
  16.        
  17.        
  18.         public StoneScreen(TombStone gam)        {
  19.         this.game = gam;
  20.        
  21.        
  22.        
  23.                 camera = new OrthographicCamera();
  24.                 camera.setToOrtho(false, 136, 204);
  25.                
  26.                 game.assets.load();
  27.                 loadStandard();
  28.                
  29.                
  30.                
  31.                        
  32.                
  33.         }
  34.        
  35.         public void loadStandard(){
  36.                 background = game.assets.background;
  37.                 sdStone = game.assets.sdStone;
  38.                 //backgrounds = Assets.backgrounds;
  39.         }
  40.  
  41.        
  42.        
  43.         @Override
  44.         public void render(float delta) {
  45.                 Gdx.gl.glClearColor(0, 0, 0.2f,1);
  46.                 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  47.                
  48.                 //Recieves the screen width and height
  49.                 float gameHeight = Gdx.graphics.getHeight();
  50.         float gameWidth = Gdx.graphics.getWidth();
  51.        
  52.        
  53.                 camera.update();
  54.                 game.batch.setProjectionMatrix(camera.combined);
  55.                
  56.                
  57.                 game.batch.begin();
  58.                 Gdx.app.log("X", "FPS:" + Gdx.graphics.getFramesPerSecond());
  59.                
  60.                
  61.                
  62.                 game.batch.draw(background,0,0, 136, 204);
  63.                
  64.                 game.batch.draw(sdStone, 40, 20, 70, 110);
  65.                
  66.                 //SpriteBatch batcher = (SpriteBatch)stage.getBatch();
  67.                
  68.                
  69.                 game.batch.end();
  70.                
  71.                 stage.act();
  72.                 stage.draw();
  73.         }
  74.        
  75.        
  76.  
  77.         @Override
  78.         public void resize(int width, int height) {
  79.                 // TODO Auto-generated method stub
  80.                
  81.         }
  82.  
  83.         @Override
  84.         public void show() {
  85.                  
  86.                 String text = Gdx.app.getPreferences("prefs").getString("text", "Default text if missing");
  87.                 String txtArea = Gdx.app.getPreferences("prefs").getString("text", "Default text if missing");
  88.                
  89.                
  90.                
  91.                 Skin skin = new Skin();
  92.        
  93.                 stage = new Stage();
  94.                 Gdx.input.setInputProcessor(stage);
  95.                 skin = new Skin(Gdx.files.internal("uiskin.json"));
  96.                 TextArea textArea = new TextArea(txtArea, skin);
  97.                 textArea.setX(500);
  98.                 textArea.setY(500);
  99.                 textArea.setWidth(270);
  100.                 textArea.setHeight(270);
  101.                
  102.                
  103.                 TextField textField = new TextField(text, skin);
  104.                 textField.setX(500);
  105.                 textField.setY(750);
  106.                 textField.setWidth(450);
  107.                 textField.setHeight(200);
  108.                
  109.                
  110.                
  111.                 //String text = Gdx.app.getPreferences("prefs").getString("text", "Default text if missimg");
  112.                 //TextField textField = new TextField(text, skin);
  113.                
  114.                 //Backbutton
  115.                                 ImageButtonStyle styleTwo = new ImageButtonStyle();
  116.                                 TextureRegionDrawable arrowImage = new TextureRegionDrawable(new TextureRegion(new Texture("arrowLeft.png")));
  117.                                 styleTwo.up = skin.newDrawable(skin.newDrawable(arrowImage));
  118.                                 styleTwo.down = skin.newDrawable(skin.newDrawable(arrowImage));
  119.                
  120.         btnArrow = new ImageButton(styleTwo);
  121.                
  122.                 btnArrow.setSize(150, 150);
  123.                 btnArrow.setPosition(450, 10);
  124.                
  125.                 stage.addActor(textArea);
  126.                 stage.addActor(textField);
  127.                 stage.addActor(btnArrow);
  128.                
  129.                
  130.                 //Backbutton takes us back to mainmenu
  131.                                 btnArrow.addListener(new ChangeListener() {
  132.  
  133.                                         @Override
  134.                                         public void changed(ChangeEvent event, Actor actor) {
  135.                                                 game.setScreen(new MainScreen(game));
  136.                                                
  137.                                         }
  138.  
  139.                                
  140.                         });
  141.                
  142.         }
  143.  
  144.         @Override
  145.         public void hide() {
  146.                 // TODO Auto-generated method stub
  147.                
  148.         }
  149.  
  150.         @Override
  151.         public void pause() {
  152.                 // TODO Auto-generated method stub
  153.                
  154.         }
  155.  
  156.         @Override
  157.         public void resume() {
  158.                 // TODO Auto-generated method stub
  159.                
  160.         }
  161.  
  162.         @Override
  163.         public void dispose() {
  164.                 // TODO Auto-generated method stub
  165.                
  166.         }
  167.  
  168.        
  169.        
  170.        
  171. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top