我一直在尝试使用g.drawString()从另一个类中绘制一个String变量;方法。这是我的代码:
g2.drawString(lang.menu[i], MainPanel.SCREEN_WIDTH / 2, MainPanel.SCREEN_HEIGHT / 2 + i * 22);
我试过让Lang.menu [] String静态而不是静态,但它似乎根本没有影响它。有什么帮助吗?
Lang.menu []:
public String[] menu;{
if(Main.langPicked == 1){
menu[0] = "Singleplayer";
menu[1] = "Multiplayer";
menu[2] = "Options";
menu[3] = "Exit Game";
}else if(Main.langPicked == 2){
menu[0] = "Solo";
menu[1] = "Multijoueur";
menu[2] = "Options";
menu[3] = "Quitter Le Jeu";
}else if(Main.langPicked == 3){
menu[0] = "Singleplayer";
menu[1] = "Multiplayer";
menu[2] = "Opties";
menu[3] = "Verlaat Het Spel";
}
}
答案 0 :(得分:0)
尝试添加此内容,然后调用fillMenu()
public String[] menu;
public void fillMenu()
{
menu = new String[4];
if(Main.langPicked == 1) {
menu[0] = "Singleplayer";
menu[1] = "Multiplayer";
menu[2] = "Options";
menu[3] = "Exit Game";
}
else if(Main.langPicked == 2) {
menu[0] = "Solo";
menu[1] = "Multijoueur";
menu[2] = "Options";
menu[3] = "Quitter Le Jeu";
}
else if(Main.langPicked == 3) {
menu[0] = "Singleplayer";
menu[1] = "Multiplayer";
menu[2] = "Opties";
menu[3] = "Verlaat Het Spel";
}
}