SHARE
TWEET

Untitled

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