Пример #1
0
 @Override
 public void update(GameContainer container, int delta) throws SlickException {
   if (input != null) {
     GameCore.getInstance().setActive(new Scores(score, victory, input));
     container.getInput().isKeyPressed(Controls.accept);
   }
 }
Пример #2
0
  @SuppressWarnings("unchecked")
  public GameOver(String text, int score, boolean victory) {
    this.text = text;
    this.score = score;
    this.victory = victory;
    font = new UnicodeFont(Database.instance().getDefaultFont().getFont(), 50, true, false);

    font.addAsciiGlyphs();
    font.getEffects().add(new ColorEffect());
    try {
      font.loadGlyphs();
    } catch (SlickException e1) {
      e1.printStackTrace();
    }

    nameInput =
        new TextField(
            GameCore.getInstance().getApp(),
            Database.instance().getDefaultFont(),
            150,
            20,
            500,
            Database.instance().getDefaultFont().getLineHeight() + 20,
            new ComponentListener() {
              public void componentActivated(AbstractComponent source) {
                input = nameInput.getText();
              }
            });
    nameInput.setFocus(true);
    nameInput.setBorderColor(Color.black);
    nameInput.setText("Anonymous");
    nameInput.setMaxLength(20);
  }