コード例 #1
0
  public void signIn() {
    menu = Assets.menuSigninRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new ArrayList<TextField>();

    menuComponents.add(0, new MenuComponent(200, 300, 100, 50, Assets.menuUsernameRegion));
    menuComponents.add(1, new MenuComponent(200, 200, 100, 50, Assets.menuPasswordRegion));
    menuComponents.add(2, new MenuComponent(600, 50, 100, 50, Assets.menuSubmitRegion));

    Skin usernameSkin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextField usernameTextField = new TextField("", usernameSkin);
    usernameTextField.setPosition(300, 300);
    usernameTextField.setWidth(400);
    usernameTextField.setFocusTraversal(false);
    Skin passwordSkin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextField passwordTextField = new TextField("", passwordSkin);
    passwordTextField.setPosition(300, 200);
    passwordTextField.setPasswordMode(true);
    passwordTextField.setPasswordCharacter('a');
    passwordTextField.setWidth(400);
    passwordTextField.setFocusTraversal(false);
    menuTextFields.add(0, usernameTextField);
    menuTextFields.add(1, passwordTextField);

    menuNumber = 2;
  }
コード例 #2
0
  public void gameOver(
      boolean won, ArrayList<Integer> playerIDs, ArrayList<String> playerUsernames) {
    shouldClear = true;
    shouldAddScrollPane = false;
    charityScrollPane = false;
    characterScrollPane = false;
    scrollPaneContainer = null;
    menu = Assets.menuSplashBlankRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new HashMap<String, TextField>();
    menuNumber = this.MENU_GAMEOVER;
    this.isSplash = false;

    TextField resultsTextField = new TextField(("YOU LOSE"), Assets.tfsTrans100);
    resultsTextField.setPosition(50, 350);
    resultsTextField.setWidth(700);
    resultsTextField.setHeight(150);
    resultsTextField.setAlignment(Align.center);
    resultsTextField.setFocusTraversal(false);
    resultsTextField.setDisabled(true);

    if (won) {
      resultsTextField.setText("YOU WIN!");
    }

    int yOffset = 0;
    for (String s : playerUsernames) // for each player passed in
    {
      TextField playerTextField = new TextField(s, Assets.tfsTrans40);
      playerTextField.setPosition(50, 260 - (yOffset * 70));
      playerTextField.setWidth(300);
      playerTextField.setHeight(50);
      playerTextField.setAlignment(Align.left);
      playerTextField.setFocusTraversal(false);
      playerTextField.setDisabled(true);

      TextField friendTextField =
          new TextField(Integer.toString(playerIDs.get(yOffset)), Assets.tfsTrans40);
      friendTextField.setPosition(400, 260 - (yOffset * 70));
      friendTextField.setWidth(300);
      friendTextField.setHeight(50);
      friendTextField.setAlignment(Align.left);
      friendTextField.setFocusTraversal(false);
      friendTextField.setDisabled(true);

      yOffset++;
      menuTextFields.put(s, playerTextField);
    }

    menuTextFields.put("resultsTF", resultsTextField);
  }
コード例 #3
0
  public void pickClass() {
    shouldClear = true;
    shouldAddScrollPane = true;
    charityScrollPane = false;
    characterScrollPane = true;
    menu = Assets.menuSplashBlankRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new HashMap<String, TextField>();

    menuComponents.add(
        0, new MenuComponent(700, 100, 175, 75, Assets.menuButtonSmallRegion)); // continue
    menuComponents.add(
        1, new MenuComponent(100, 100, 175, 75, Assets.menuButtonSmallRegion)); // return

    final TextField characterTextField =
        new TextField(
            "SELECT A CHARACTER",
            Assets.tfsTrans40); // obviously want to replace these with a real charity selection
    characterTextField.setPosition(50, 390);
    characterTextField.setWidth(700);
    characterTextField.setHeight(50);
    characterTextField.setAlignment(Align.center);
    characterTextField.setFocusTraversal(false);
    characterTextField.setDisabled(true);

    TextField continueTextField = new TextField(("CONTINUE"), Assets.tfsTransWhite40);
    continueTextField.setPosition(612, 27);
    continueTextField.setWidth(175); // to be centered well make the width about 325
    continueTextField.setHeight(50);
    continueTextField.setAlignment(Align.center);
    continueTextField.setFocusTraversal(false);
    continueTextField.setDisabled(true);

    TextField returnTextField = new TextField(("RETURN"), Assets.tfsTransWhite40);
    returnTextField.setPosition(12, 27);
    returnTextField.setWidth(175); // to be centered well make the width about 325
    returnTextField.setHeight(50);
    returnTextField.setAlignment(Align.center);
    returnTextField.setFocusTraversal(false);
    returnTextField.setDisabled(true);

    menuTextFields.put("characterTF", characterTextField);
    menuTextFields.put("continueTF", continueTextField);
    menuTextFields.put("returnTF", returnTextField);

    menuNumber = this.MENU_PICK_CLASS;
  }
コード例 #4
0
  public void welcome(String username, int wins, int losses, String charityName, int charityIcon) {
    menu = Assets.menuWelcomeRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new ArrayList<TextField>();

    Skin usernameSkin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextField usernameTextField = new TextField(username, usernameSkin);
    usernameTextField.setPosition(300, 400);
    usernameTextField.setWidth(400);
    usernameTextField.setFocusTraversal(false);
    usernameTextField.setDisabled(true);

    TextField winsTextField = new TextField(String.valueOf(wins), usernameSkin);
    winsTextField.setPosition(300, 300);
    winsTextField.setWidth(400);
    winsTextField.setFocusTraversal(false);
    winsTextField.setDisabled(true);

    TextField lossesTextField = new TextField(String.valueOf(losses), usernameSkin);
    lossesTextField.setPosition(300, 200);
    lossesTextField.setWidth(400);
    lossesTextField.setFocusTraversal(false);
    lossesTextField.setDisabled(true);

    TextField charityTextField = new TextField(charityName, usernameSkin);
    charityTextField.setPosition(300, 100);
    charityTextField.setWidth(400);
    charityTextField.setFocusTraversal(false);
    charityTextField.setDisabled(true);

    menuTextFields.add(0, usernameTextField);
    menuTextFields.add(1, winsTextField);
    menuTextFields.add(2, lossesTextField);
    menuTextFields.add(3, charityTextField);

    menuNumber = 3;
  }
コード例 #5
0
  public MathsScreen(Game g) {
    game = g;
    stage = new Stage();
    Gdx.input.setInputProcessor(stage); // get input from our stage

    num1 = MathUtils.random(10, 100); // libgdx easy random numbers :)
    num2 = MathUtils.random(10, 100);
    ans = num1 * num2;

    Skin skin =
        new Skin(
            Gdx.files.internal(
                "uiskin.json")); // set what the UI elements are going to look like, libgdx provides
    // file abstraction to make it easy to access files on any platform

    question =
        new Label(
            "What is the area of a rectangle of   " + num1 + "    by    " + num2,
            skin); // Create a label element
    question.setPosition(100, 500); // Position it
    stage.addActor(question); // Add the lable to the stage

    answer = new TextField("", skin); // Create a textfield element
    answer.setPosition(300, 340); // Position it
    stage.addActor(answer); // Add it to the stage

    feedback = new Label("", skin); // Create a label element
    feedback.setPosition(300, 150); // Position it
    stage.addActor(feedback); // Add the lable to the stage

    check = new TextButton("Check your answer", skin);
    check.setPosition(300, 200);
    check.addListener(
        new ClickListener() // add the listener as an anonymous? method, inline method
        {
          // autocomplete the code below by typing clicked and then ctrl + space, modify to add our
          // own btClicked method
          public void clicked(InputEvent e, float x, float y) {
            btnClicked();
          }
        });
    stage.addActor(check);
  }
コード例 #6
0
  public void welcome(String username, int wins, int losses, String charityName, int charityIcon) {
    shouldClear = true;
    shouldAddScrollPane = false;
    charityScrollPane = false;
    characterScrollPane = false;
    scrollPaneContainer = null;
    menu = Assets.menuSplashBlankRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new HashMap<String, TextField>();

    TextField usernameTextField =
        new TextField(("WELCOME " + username.toUpperCase() + "!"), Assets.tfsBigBlue70);
    usernameTextField.setPosition(50, 290);
    usernameTextField.setWidth(700);
    usernameTextField.setHeight(50);
    usernameTextField.setAlignment(Align.center);
    usernameTextField.setFocusTraversal(false);
    usernameTextField.setDisabled(true);

    menuTextFields.put("usernameTF", usernameTextField);

    menuNumber = this.MENU_WELCOME;
  }
コード例 #7
0
  public void splash() {
    shouldClear = true;
    shouldAddScrollPane = false;
    charityScrollPane = false;
    characterScrollPane = false;
    scrollPaneContainer = null;
    menu = Assets.menuSplashBlankRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new HashMap<String, TextField>();
    menuNumber = this.MENU_SPLASH;
    blinkTimer = 0;

    TextField charityChampsTextField = new TextField(("CHARITY CHAMPS!"), Assets.tfsTrans100);
    charityChampsTextField.setPosition(50, 190);
    charityChampsTextField.setWidth(700);
    charityChampsTextField.setHeight(150);
    charityChampsTextField.setAlignment(Align.center);
    charityChampsTextField.setFocusTraversal(false);
    charityChampsTextField.setDisabled(true);

    menuTextFields.put("charityChampsTF", charityChampsTextField);

    this.isSplash = true;
  }
コード例 #8
0
  public void options() {
    shouldClear = true;
    shouldAddScrollPane = false;
    charityScrollPane = false;
    characterScrollPane = false;
    scrollPaneContainer = null;
    menuNumber = this.MENU_OPTIONS;
    menu = Assets.menuSplashBlankRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new HashMap<String, TextField>();
    menuComponents.add(
        0, new MenuComponent(600, 100, 175, 75, Assets.menuButtonSmallRegion)); // return
    menuComponents.add(
        1, new MenuComponent(250, 350, 175, 75, Assets.menuButtonSmallRegion)); // player
    menuComponents.add(
        2, new MenuComponent(250, 250, 175, 75, Assets.menuButtonSmallRegion)); // audio
    menuComponents.add(
        3, new MenuComponent(250, 150, 175, 75, Assets.menuButtonSmallRegion)); // privacy
    menuComponents.add(
        4, new MenuComponent(600, 350, 175, 75, Assets.menuButtonSmallRegion)); // log out

    // right now I am using the metric of setting the width to be 175 and height 50 (for textfields)
    // and making them 88 units below the buttons and 73 units below. thats maybe like 1 or 2 units
    // higher than it needs to be, but it looks aight

    TextField playerTextField = new TextField(("PLAYER"), Assets.tfsTransWhite40);
    playerTextField.setPosition(162, 277);
    playerTextField.setWidth(175); // to be centered well make the width about 325
    playerTextField.setHeight(50);
    playerTextField.setAlignment(Align.center);
    playerTextField.setFocusTraversal(false);
    playerTextField.setDisabled(true);

    TextField audioTextField = new TextField(("AUDIO"), Assets.tfsTransWhite40);
    audioTextField.setPosition(162, 177);
    audioTextField.setWidth(175);
    audioTextField.setHeight(50);
    audioTextField.setAlignment(Align.center);
    audioTextField.setFocusTraversal(false);
    audioTextField.setDisabled(true);

    TextField privacyTextField = new TextField(("PRIVACY"), Assets.tfsTransWhite40);
    privacyTextField.setPosition(162, 77);
    privacyTextField.setWidth(175);
    privacyTextField.setHeight(50);
    privacyTextField.setAlignment(Align.center);
    privacyTextField.setFocusTraversal(false);
    privacyTextField.setDisabled(true);

    TextField returnTextField = new TextField(("RETURN"), Assets.tfsTransWhite40);
    returnTextField.setPosition(512, 27);
    returnTextField.setWidth(175); // to be centered well make the width about 325
    returnTextField.setHeight(50);
    returnTextField.setAlignment(Align.center);
    returnTextField.setFocusTraversal(false);
    returnTextField.setDisabled(true);

    TextField logoutTextField = new TextField(("LOG OUT"), Assets.tfsTransWhite40);
    logoutTextField.setPosition(512, 277);
    logoutTextField.setWidth(175); // to be centered well make the width about 325
    logoutTextField.setHeight(50);
    logoutTextField.setAlignment(Align.center);
    logoutTextField.setFocusTraversal(false);
    logoutTextField.setDisabled(true);

    TextField charityChampsTextField = new TextField(("OPTIONS"), Assets.tfsTrans100);
    charityChampsTextField.setPosition(50, 390);
    charityChampsTextField.setWidth(700);
    charityChampsTextField.setHeight(50);
    charityChampsTextField.setAlignment(Align.center);
    charityChampsTextField.setFocusTraversal(false);
    charityChampsTextField.setDisabled(true);

    menuTextFields.put("playTF", playerTextField);
    menuTextFields.put("optionsTF", audioTextField);
    menuTextFields.put("privacyTF", privacyTextField);
    menuTextFields.put("returnTF", returnTextField);
    menuTextFields.put("logoutTF", logoutTextField);
    menuTextFields.put("charityChampsTF", charityChampsTextField);
  }
コード例 #9
0
  public void mainMenu() {
    shouldClear = true;
    shouldAddScrollPane = false;
    charityScrollPane = false;
    characterScrollPane = false;
    scrollPaneContainer = null;
    menu = Assets.menuSplashBlankRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new HashMap<String, TextField>();
    menuComponents.add(
        0, new MenuComponent(200, 350, 175, 75, Assets.menuButtonSmallRegion)); // play button
    menuComponents.add(
        1, new MenuComponent(200, 250, 175, 75, Assets.menuButtonSmallRegion)); // options button
    menuComponents.add(
        2, new MenuComponent(200, 150, 175, 75, Assets.menuButtonSmallRegion)); // profile button

    // right now I am using the metric of setting the width to be 175 and height 50 (for textfields)
    // and making them 88 units below the buttons and 73 units below. thats maybe like 1 or 2 units
    // higher than it needs to be, but it looks aight

    TextField playTextField = new TextField(("PLAY!"), Assets.tfsTransWhite40);
    playTextField.setPosition(112, 277);
    playTextField.setWidth(175); // to be centered well make the width about 325
    playTextField.setHeight(50);
    playTextField.setAlignment(Align.center);
    playTextField.setFocusTraversal(false);
    playTextField.setDisabled(true);

    TextField optionsTextField = new TextField(("OPTIONS"), Assets.tfsTransWhite40);
    optionsTextField.setPosition(112, 177);
    optionsTextField.setWidth(175);
    optionsTextField.setHeight(50);
    optionsTextField.setAlignment(Align.center);
    optionsTextField.setFocusTraversal(false);
    optionsTextField.setDisabled(true);

    TextField profileTextField = new TextField(("PROFILE"), Assets.tfsTransWhite40);
    profileTextField.setPosition(112, 77);
    profileTextField.setWidth(175);
    profileTextField.setHeight(50);
    profileTextField.setAlignment(Align.center);
    profileTextField.setFocusTraversal(false);
    profileTextField.setDisabled(true);

    TextField charityChampsTextField = new TextField(("CHARITY CHAMPS"), Assets.tfsTrans100);
    charityChampsTextField.setPosition(50, 390);
    charityChampsTextField.setWidth(700);
    charityChampsTextField.setHeight(50);
    charityChampsTextField.setAlignment(Align.center);
    charityChampsTextField.setFocusTraversal(false);
    charityChampsTextField.setDisabled(true);

    Leaderboard leaderboard = new Leaderboard(game.getPlayerID(), 5, 0);
    int yOffset = 0;
    TreeMap<Integer, Integer> sortedMap = new TreeMap<Integer, Integer>();

    for (Integer id : leaderboard.board.keySet()) // for each (INT, <String, String>)
    {
      System.out.println(
          "sorting " + Integer.parseInt(leaderboard.board.get(id).get("WINS")) + " " + id);
      sortedMap.put(Integer.parseInt(leaderboard.board.get(id).get("WINS")), id);
    }

    System.out.println(sortedMap.descendingMap());

    for (Integer id :
        sortedMap
            .descendingMap()
            .values()) { // the values, is the id. should do it in the order of wins highest

      TextField playerTextField =
          new TextField(leaderboard.board.get(id).get("USERNAME"), Assets.tfsTrans40);
      playerTextField.setPosition(400, 260 - (yOffset * 70));
      playerTextField.setWidth(300);
      playerTextField.setHeight(50);
      playerTextField.setAlignment(Align.left);
      playerTextField.setFocusTraversal(false);
      playerTextField.setDisabled(true);

      TextField winsTextField =
          new TextField(leaderboard.board.get(id).get("WINS"), Assets.tfsTrans40);
      winsTextField.setPosition(700, 260 - (yOffset * 70));
      winsTextField.setWidth(100);
      winsTextField.setHeight(50);
      winsTextField.setAlignment(Align.left);
      winsTextField.setFocusTraversal(false);
      winsTextField.setDisabled(true);

      yOffset++;
      menuTextFields.put(leaderboard.board.get(id).get("USERNAME"), playerTextField);
      menuTextFields.put(leaderboard.board.get(id).get("WINS"), winsTextField);
    }

    menuTextFields.put("playTF", playTextField);
    menuTextFields.put("optionsTF", optionsTextField);
    menuTextFields.put("profileTF", profileTextField);
    menuTextFields.put("charityChampsTF", charityChampsTextField);

    menuNumber = this.MENU_MAINMENU;
  }
コード例 #10
0
  public void signUp() {
    shouldClear = true;
    // shouldAddScrollPane = false;
    shouldAddScrollPane = true;
    charityScrollPane = true;
    characterScrollPane = false;
    menu = Assets.menuSplashBlankRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new HashMap<String, TextField>();

    menuComponents.add(
        0, new MenuComponent(600, 100, 175, 75, Assets.menuButtonSmallRegion)); // submit
    menuComponents.add(
        1, new MenuComponent(400, 100, 175, 75, Assets.menuButtonSmallRegion)); // return

    // right now I am using the metric of setting the width to be 175 and height 50 (for textfields)
    // and making them 88 units below the buttons and 73 units below. thats maybe like 1 or 2 units
    // higher than it needs to be, but it looks aight

    TextField signUpTextField = new TextField(("SIGN UP!"), Assets.tfsTrans100);
    signUpTextField.setPosition(50, 330);
    signUpTextField.setWidth(700);
    signUpTextField.setHeight(150);
    signUpTextField.setAlignment(Align.center);
    signUpTextField.setFocusTraversal(false);
    signUpTextField.setDisabled(true);

    TextField returnTextField = new TextField(("RETURN"), Assets.tfsTransWhite40);
    returnTextField.setPosition(312, 27);
    returnTextField.setWidth(175); // to be centered well make the width about 325
    returnTextField.setHeight(50);
    returnTextField.setAlignment(Align.center);
    returnTextField.setFocusTraversal(false);
    returnTextField.setDisabled(true);

    TextField submitTextField = new TextField(("SUBMIT"), Assets.tfsTransWhite40);
    submitTextField.setPosition(512, 27);
    submitTextField.setWidth(175);
    submitTextField.setHeight(50);
    submitTextField.setAlignment(Align.center);
    submitTextField.setFocusTraversal(false);
    submitTextField.setDisabled(true);

    final TextField usernameTextField = new TextField("USERNAME", Assets.tfs);
    usernameTextField.setPosition(100, 300);
    usernameTextField.setWidth(300);
    usernameTextField.setHeight(50);
    usernameTextField.setFocusTraversal(false);
    usernameTextField.addListener(
        new ClickListener() {
          public void clicked(InputEvent e, float x, float y) {
            if (usernameTextField.getText().equals("USERNAME")) usernameTextField.setText("");
          }
        });
    usernameTextField.setTextFieldListener(
        new TextField.TextFieldListener() { // if enter is pressed, remove the keyboard
          @Override
          public void keyTyped(TextField textField, char c) {
            if ((c == '\r') || (c == '\n')) {
              Gdx.input.setOnscreenKeyboardVisible(false);
              unfocusAll = true;
            }
          }
        });

    final TextField passwordTextField = new TextField("PASSWORD", Assets.tfs);
    // passwordTextField.setPosition(100, 240);
    passwordTextField.setPosition(450, 300);
    passwordTextField.setPasswordMode(false);
    // passwordTextField.setPasswordCharacter('*');
    passwordTextField.setWidth(300);
    passwordTextField.setHeight(50);
    passwordTextField.setFocusTraversal(false);
    passwordTextField.addListener(
        new ClickListener() {
          public void clicked(InputEvent e, float x, float y) {
            if (passwordTextField.getText().equals("PASSWORD"))
              passwordTextField.setPasswordMode(true);
            passwordTextField.setPasswordCharacter('*');
            passwordTextField.setText("");
          }
        });
    passwordTextField.setTextFieldListener(
        new TextField.TextFieldListener() { // if enter is pressed, remove the keyboard
          @Override
          public void keyTyped(TextField textField, char c) {
            if ((c == '\r') || (c == '\n')) {
              Gdx.input.setOnscreenKeyboardVisible(false);
              unfocusAll = true;
            }
          }
        });

    /*final TextField emailTextField = new TextField("EMAIL", Assets.tfs);
    emailTextField.setPosition(450, 300);
    emailTextField.setWidth(300);
    emailTextField.setHeight(50);
    emailTextField.setFocusTraversal(false);
    emailTextField.addListener(new ClickListener() {
        public void clicked(InputEvent e, float x, float y) {
            if (emailTextField.getText().equals("EMAIL"))
                emailTextField.setText("");

        }
    });
    emailTextField.setTextFieldListener(new TextField.TextFieldListener() {//if enter is pressed, remove the keyboard
        @Override
        public void keyTyped(TextField textField, char c) {
            if ((c == '\r') || (c == '\n')) {
                Gdx.input.setOnscreenKeyboardVisible(false);
                unfocusAll = true;
            }
        }
    });*/

    final TextField charityTextField =
        new TextField(
            "SELECT A CHARITY",
            Assets.tfsTrans40); // obviously want to replace these with a real charity selection
    charityTextField.setPosition(250, 240);
    charityTextField.setDisabled(true);
    charityTextField.setWidth(300);
    charityTextField.setHeight(50);
    charityTextField.setFocusTraversal(false);

    menuTextFields.put("usernameTF", usernameTextField);
    menuTextFields.put("passwordTF", passwordTextField);
    // menuTextFields.put("emailTF", emailTextField);
    menuTextFields.put("charityTF", charityTextField);
    menuTextFields.put("returnTF", returnTextField);
    menuTextFields.put("submitTF", submitTextField);
    menuTextFields.put("signUpTF", signUpTextField);

    menuNumber = this.MENU_SIGNUP;
  }
コード例 #11
0
  public void signIn() {
    shouldClear = true;
    shouldAddScrollPane = false;
    charityScrollPane = false;
    characterScrollPane = false;
    scrollPaneContainer = null;
    menu = Assets.menuSplashBlankRegion;
    menuComponents = new ArrayList<MenuComponent>();
    menuTextFields = new HashMap<String, TextField>();

    menuComponents.add(
        0, new MenuComponent(600, 100, 175, 75, Assets.menuButtonSmallRegion)); // lets go
    menuComponents.add(
        1, new MenuComponent(400, 100, 175, 75, Assets.menuButtonSmallRegion)); // sign up

    // right now I am using the metric of setting the width to be 175 and height 50 (for textfields)
    // and making them 88 units below the buttons and 73 units below. thats maybe like 1 or 2 units
    // higher than it needs to be, but it looks aight

    menuComponents.add(2, new MenuComponent(45, 45, 178, 267, Assets.menuSpenceRegion));

    TextField logInTextField = new TextField(("LOG IN"), Assets.tfsTrans100);
    logInTextField.setPosition(50, 330);
    logInTextField.setWidth(700);
    logInTextField.setHeight(150);
    logInTextField.setAlignment(Align.center);
    logInTextField.setFocusTraversal(false);
    logInTextField.setDisabled(true);

    TextField letsGoTextField = new TextField(("LETS GO"), Assets.tfsTransWhite40);
    letsGoTextField.setPosition(512, 27);
    letsGoTextField.setWidth(175); // to be centered well make the width about 325
    letsGoTextField.setHeight(50);
    letsGoTextField.setAlignment(Align.center);
    letsGoTextField.setFocusTraversal(false);
    letsGoTextField.setDisabled(true);

    TextField signUpTextField = new TextField(("SIGN UP"), Assets.tfsTransWhite40);
    signUpTextField.setPosition(312, 27);
    signUpTextField.setWidth(175);
    signUpTextField.setHeight(50);
    signUpTextField.setAlignment(Align.center);
    signUpTextField.setFocusTraversal(false);
    signUpTextField.setDisabled(true);

    final TextField usernameTextField = new TextField("USERNAME", Assets.tfs);
    usernameTextField.setPosition(50, 270);
    usernameTextField.setWidth(300);
    usernameTextField.setHeight(50);
    usernameTextField.setFocusTraversal(false);
    usernameTextField.addListener(
        new ClickListener() {
          public void clicked(InputEvent e, float x, float y) {
            if (usernameTextField.getText().equals("USERNAME")) usernameTextField.setText("");
          }
        });
    usernameTextField.setTextFieldListener(
        new TextField.TextFieldListener() { // if enter is pressed, remove the keyboard
          @Override
          public void keyTyped(TextField textField, char c) {
            if ((c == '\r') || (c == '\n')) {
              Gdx.input.setOnscreenKeyboardVisible(false);
              unfocusAll = true;
            }
          }
        });

    final TextField passwordTextField = new TextField("PASSWORD", Assets.tfs);
    passwordTextField.setPosition(450, 270);
    passwordTextField.setPasswordMode(false);
    // passwordTextField.setPasswordCharacter('*');
    passwordTextField.setWidth(300);
    passwordTextField.setHeight(50);
    passwordTextField.setFocusTraversal(false);
    passwordTextField.addListener(
        new ClickListener() {
          public void clicked(InputEvent e, float x, float y) {
            if (passwordTextField.getText().equals("PASSWORD"))
              passwordTextField.setPasswordMode(true);
            passwordTextField.setPasswordCharacter('*');
            passwordTextField.setText("");
          }
        });
    passwordTextField.setTextFieldListener(
        new TextField.TextFieldListener() { // if enter is pressed, remove the keyboard
          @Override
          public void keyTyped(TextField textField, char c) {
            if ((c == '\r') || (c == '\n')) {
              Gdx.input.setOnscreenKeyboardVisible(false);
              unfocusAll = true;
            }
          }
        });

    menuTextFields.put("usernameTF", usernameTextField);
    menuTextFields.put("passwordTF", passwordTextField);
    menuTextFields.put("letsGoTF", letsGoTextField);
    menuTextFields.put("signUpTF", signUpTextField);
    menuTextFields.put("loginTF", logInTextField);

    menuNumber = this.MENU_SIGNIN;
  }
コード例 #12
0
  @Override
  public void show() {
    // Creates an stage that contains all the GUI elements
    stage = new Stage();
    stage.clear();
    Gdx.input.setInputProcessor(stage);

    // Title label
    font100orange = new BitmapFont(Gdx.files.internal("fonts/prehistorik100orange.fnt"));
    titleLabel = new Label(this.title, new LabelStyle(font100orange, Color.WHITE));
    titleLabel.setPosition(
        Gdx.graphics.getWidth() / 2.0f - titleLabel.getWidth() / 2,
        7.1f * Gdx.graphics.getHeight() / 9.0f);

    // Textbox label
    white30boldFont = new BitmapFont(Gdx.files.internal("fonts/white30bold.fnt"));
    label1 = new Label("IP adress of game creator:", new LabelStyle(white30boldFont, Color.WHITE));
    label1.setPosition(
        Gdx.graphics.getWidth() / 2.0f - label1.getWidth() / 2,
        6 * Gdx.graphics.getHeight() / 9.0f);

    // Username
    Label usernameLabel = ScreenUtils.createLabel("Username:"******"", 0, 0);
    usernameInput.setPosition(
        Gdx.graphics.getWidth() / 2f - usernameInput.getWidth() / 2f,
        3 * Gdx.graphics.getHeight() / 9.0f);

    // Atlas of the GUI
    atlas = new TextureAtlas("gui/gui.pack");
    skin = new Skin(atlas);

    // Buttons
    font60 = new BitmapFont(Gdx.files.internal("fonts/prehistorik60black.fnt"), false);
    TextButtonStyle buttonStyle = new TextButtonStyle();
    buttonStyle.up = skin.getDrawable("button1");
    buttonStyle.over = skin.getDrawable("button1-over");
    buttonStyle.down = skin.getDrawable("button1-down");
    buttonStyle.font = font60;

    joinButton = new TextButton("Join Game", buttonStyle);
    joinButton.setHeight(100f);
    joinButton.setWidth(500f);
    joinButton.setPosition(
        Gdx.graphics.getWidth() / 2.0f - joinButton.getWidth() / 2,
        1.5f * Gdx.graphics.getHeight() / 9.0f);

    menuButton = new TextButton("Main Menu", buttonStyle);
    menuButton.setHeight(100f);
    menuButton.setWidth(500f);
    menuButton.setPosition(
        Gdx.graphics.getWidth() / 2.0f - joinButton.getWidth() / 2,
        0f * Gdx.graphics.getHeight() / 9.0f);

    // TextField
    white36nonoFont = new BitmapFont(Gdx.files.internal("fonts/white36mono.fnt"));
    TextFieldStyle tfs = new TextFieldStyle();
    tfs.font = white36nonoFont;
    tfs.cursor = skin.getDrawable("cursor");
    tfs.background = skin.getDrawable("textField");
    tfs.fontColor = Color.WHITE;
    inputAddress = new TextField("localhost", tfs);
    inputAddress.setHeight(50);
    inputAddress.setWidth(300);
    inputAddress.setPosition(
        Gdx.graphics.getWidth() / 2.0f - inputAddress.getWidth() / 2,
        5 * Gdx.graphics.getHeight() / 9.0f);

    // add actors
    stage.addActor(joinButton);
    stage.addActor(menuButton);
    stage.addActor(inputAddress);
    stage.addActor(titleLabel);
    stage.addActor(usernameLabel);
    stage.addActor(usernameInput);
    stage.addActor(titleLabel);
    stage.addActor(label1);

    joinButton.addListener(
        new ChangeListener() {

          @Override
          public void changed(ChangeEvent event, Actor actor) {
            System.out.println(inputAddress.getText());

            GameScreen.createInstance(game, false, inputAddress.getText(), usernameInput.getText());
            game.setScreen(GameScreen.getInstance());
            //						game.initInputListeners();

          }
        });

    menuButton.addListener(
        new ChangeListener() {

          @Override
          public void changed(ChangeEvent event, Actor actor) {
            game.setScreen(new MenuScreen(game));
          }
        });
  }
コード例 #13
0
  @Override
  public void create() {

    //		Gdx.gl.glClearColor(
    //			background.rgb.getRed() / 255f,
    //			background.rgb.getGreen() / 255f,
    //			background.rgb.getBlue() / 255f,
    //			background.rgb.getAlpha() / 255f);
    //		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    //		Gdx.graphics.setContinuousRendering(false);
    //		Gdx.graphics.requestRendering();

    cam = new OrthographicCamera();
    batch = new SpriteBatch();

    stage = new Stage();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    input = new TextField("", skin);

    // can't use Table here since it will conflict with the Swing Table toolkit
    // this is why static is shit -.-
    labelInput = new Label("Sample Text:", skin);
    labelScale = new Label("Scale:", skin);
    scaleAmt = new Label("1.0", skin);

    labelInput.setHeight(input.getHeight());
    labelInput.setPosition(10, Gdx.graphics.getHeight() - labelInput.getHeight() - 5);
    input.setPosition(
        labelInput.getX() + labelInput.getWidth() + 10,
        Gdx.graphics.getHeight() - input.getHeight() - 5);

    scaleSlider = new Slider(0, 3, 0.05f, false, skin);
    scaleSlider.setSnapToValues(new float[] {0.0f, 0.5f, 1.0f}, 0.05f);

    scaleSlider.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent arg0, Actor arg1) {
            scaleAmt.setText(String.format("%.2f", scaleSlider.getValue()));
          }
        });
    scaleSlider.setValue(1.0f);
    scaleAmt.setText(String.format("%.2f", scaleSlider.getValue()));

    linearFiltering = new ToggleBox("Linear Filtering", skin);
    linearFiltering.addListener(
        new ClickListener() {
          public void clicked(InputEvent ev, float x, float y) {
            updateFiltering();
          }
        });

    scaleAmt.setHeight(scaleSlider.getHeight());
    labelScale.setHeight(scaleSlider.getHeight());

    labelScale.setPosition(
        input.getX() - 10 - labelScale.getWidth(), labelInput.getY() - labelInput.getHeight() - 5);
    scaleSlider.setPosition(input.getX(), input.getY() - input.getHeight() - 5);
    scaleAmt.setPosition(scaleSlider.getX() + scaleSlider.getWidth() + 5, scaleSlider.getY());

    linearFiltering.setPosition(input.getX(), scaleSlider.getY() - scaleSlider.getHeight() - 10);

    Gdx.input.setInputProcessor(stage);
    stage.addActor(labelInput);
    stage.addActor(input);
    stage.addActor(labelScale);
    stage.addActor(scaleSlider);
    stage.addActor(scaleAmt);
    stage.addActor(linearFiltering);

    myButton = new TextButton("Blah", skin);
  }