I’ve tested TextField on a clean BasicGame and it worked. (I see the border and i can type.)
The code:
TextField lanText;
TrueTypeFont font;
public void init(........)
{
font = new TrueTypeFont(new java.awt.Font(java.awt.Font.SERIF,java.awt.Font.BOLD,8),false);
lanText = new TextField(gc, font, 50, 100, 350, 25);
}
public void render(.....)
{
lanText.render(gc, g);
}
But when i try it on my game with BasicGameState it doesn’t work. What’s wrong? (I can see the border but I cant type)
I have 4 states. Menu 0. Game 1. Coop 2. Options 3.
Im trying to add it to the state 2(Coop).
public class Game
extends StateBasedGame
{
public final int menu = 0;
public final int game = 1;
public final int option = 2;
public final int coop = 3;
public Game(String gamename)
{
super(gamename);
this.addState(new Menu(menu));
this.addState(new Game(game));
this.addState(new Option(option));
this.addState(new Coop(coop));
}
public void initStatesList(GameContainer gc)
throws SlickException
{
this.getState(menu).init(gc, this);
this.getState(game).init(gc, this);
this.getState(option).init(gc, this);
this.getState(coop).init(gc, this);
this.enterState(menu);
}
}
Ok, I figured it out. Here is the code for anyone who will have the same problem.
I don’t know why it needs to use font.loadGlyphs(); but without it, it wont work.