SHARE
TWEET

Untitled

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