SHARE
TWEET

Untitled

a guest Sep 20th, 2014 188 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void show() {
  2.                  
  3.                        
  4.                
  5.                 BitmapFont textFont;
  6.                
  7.                 FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("NothingYouCouldDoBold.ttf"));
  8.                 FreeTypeFontParameter parameter = new FreeTypeFontParameter();
  9.                 parameter.size = 12;
  10.                 textFont = generator.generateFont(parameter);
  11.                
  12.                
  13.        
  14.         //String text = Gdx.app.getPreferences("prefs").getString("text", "Default text if missing");
  15.         //String txtArea = Gdx.app.getPreferences("prefs").getString("text", "Default text if missing");
  16.         Preferences prefs = Gdx.app.getPreferences("preferences");
  17.        
  18.         Skin skin = new Skin();
  19.         Skin textSkin = new Skin();
  20.        
  21.        
  22.         stage = new Stage();
  23.         Gdx.input.setInputProcessor(stage);
  24.         skin = new Skin(Gdx.files.internal("uiskin.json"));
  25.         skin.add("font", textFont);
  26.        
  27.        
  28.        
  29.         final TextArea textArea = new TextArea(prefs.getString("textArea", "Enter text:"), skin);
  30.         textArea.setX(500);
  31.         textArea.setY(500);
  32.         textArea.setWidth(270);
  33.         textArea.setHeight(270);
  34.         textArea.setMaxLength(50);
  35.        
  36.         final TextField textField = new TextField(prefs.getString("textField", "Enter name:"), skin);
  37.                
  38.                
  39.                 textField.setX(500);
  40.                 textField.setY(750);
  41.                 textField.setMaxLength(20);
  42.                 //textField.setWidth(450);
  43.                 //textField.setHeight(200);
  44.                 textField.setSize(400, 200);
  45.                
  46.                
  47.                
  48.                
  49.                 //String text = Gdx.app.getPreferences("prefs").getString("text", "Default text if missimg");
  50.                 //TextField textField = new TextField(text, skin);
  51.                
  52.                 //Backbutton
  53.                                 ImageButtonStyle styleTwo = new ImageButtonStyle();
  54.                                 TextureRegionDrawable arrowImage = new TextureRegionDrawable(new TextureRegion(new Texture("arrowLeft.png")));
  55.                                 styleTwo.up = skin.newDrawable(skin.newDrawable(arrowImage));
  56.                                 styleTwo.down = skin.newDrawable(skin.newDrawable(arrowImage));
  57.                
  58.         btnArrow = new ImageButton(styleTwo);
  59.                
  60.                 btnArrow.setSize(150, 150);
  61.                 btnArrow.setPosition(450, 10);
  62.                
  63.                 stage.addActor(textArea);
  64.                 stage.addActor(textField);
  65.                 stage.addActor(btnArrow);
  66.                
  67.                
  68.                 //Backbutton takes us back to mainmenu
  69.                                 btnArrow.addListener(new ChangeListener() {
  70.  
  71.                                         @Override
  72.                                         public void changed(ChangeEvent event, Actor actor) {
  73.                                                 game.setScreen(new MainScreen(game));
  74.                                                 //Saves the entered text.
  75.                                                
  76.                                                 Preferences prefs = Gdx.app.getPreferences("preferences");
  77.                                                 prefs.putString("textField", textField.getText());
  78.                                                 prefs.putString("textArea", textArea.getText());
  79.                                                 prefs.flush();
  80.                                         }
  81.  
  82.                                
  83.                         });
  84.                
  85.         }
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