Exemplo n.º 1
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);
  }
Exemplo n.º 2
0
 public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
   super.init(gc, sbg);
   multiLb = new MKLabelNode("Multiplayer");
   multiLb.setPostion(new MKPoint(50, 50));
   multiLb.setFont(new Font("Verdana", Font.BOLD, 50));
   // gc font x y w h
   textField =
       new TextField(
           gc, new TrueTypeFont(new Font("Verdana", Font.BOLD, 30), false), 50, 10, 500, 50);
   textField.setText("username...");
   textField.setCursorPos("username...".length());
 }
Exemplo n.º 3
0
 /**
  * Do the undo of the paste, overrideable for custom behaviour
  *
  * @param oldCursorPos before the paste
  * @param oldText The text before the last paste
  */
 protected void doUndo(int oldCursorPos, String oldText) {
   if (oldText != null) {
     setText(oldText);
     setCursorPos(oldCursorPos);
   }
 }