SHARE
TWEET
Untitled
a guest
Sep 18th, 2014
164
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- public void show() {
- BitmapFont textFont;
- FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("NothingYouCouldDoBold.ttf"));
- FreeTypeFontParameter parameter = new FreeTypeFontParameter();
- parameter.size = 12;
- textFont = generator.generateFont(parameter);
- //String text = Gdx.app.getPreferences("prefs").getString("text", "Default text if missing");
- //String txtArea = Gdx.app.getPreferences("prefs").getString("text", "Default text if missing");
- Preferences prefs = Gdx.app.getPreferences("preferences");
- Skin skin = new Skin();
- Skin textSkin = new Skin();
- textSkin.add("font", textFont);
- stage = new Stage();
- Gdx.input.setInputProcessor(stage);
- skin = new Skin(Gdx.files.internal("uiskin.json"));
- TextFieldStyle Textstyle = new TextFieldStyle();
- Textstyle.font = textSkin.getFont("font");
- final TextArea textArea = new TextArea(prefs.getString("textArea", "Enter text:"), skin);
- textArea.setX(500);
- textArea.setY(500);
- textArea.setWidth(270);
- textArea.setHeight(270);
- textArea.setMaxLength(50);
- final TextField textField = new TextField(prefs.getString("textField", "Enter name:"), textSkin);
- textField.setX(500);
- textField.setY(750);
- textField.setMaxLength(20);
- //textField.setWidth(450);
- //textField.setHeight(200);
- textField.setSize(400, 200);
- //String text = Gdx.app.getPreferences("prefs").getString("text", "Default text if missimg");
- //TextField textField = new TextField(text, skin);
- //Backbutton
- ImageButtonStyle styleTwo = new ImageButtonStyle();
- TextureRegionDrawable arrowImage = new TextureRegionDrawable(new TextureRegion(new Texture("arrowLeft.png")));
- styleTwo.up = skin.newDrawable(skin.newDrawable(arrowImage));
- styleTwo.down = skin.newDrawable(skin.newDrawable(arrowImage));
- btnArrow = new ImageButton(styleTwo);
- btnArrow.setSize(150, 150);
- btnArrow.setPosition(450, 10);
- stage.addActor(textArea);
- stage.addActor(textField);
- stage.addActor(btnArrow);
- //Backbutton takes us back to mainmenu
- btnArrow.addListener(new ChangeListener() {
- @Override
- public void changed(ChangeEvent event, Actor actor) {
- game.setScreen(new MainScreen(game));
- //Saves the entered text.
- Preferences prefs = Gdx.app.getPreferences("preferences");
- prefs.putString("textField", textField.getText());
- prefs.putString("textArea", textArea.getText());
- prefs.flush();
- }
- });
- }
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.
