嘿伙计们,我想知道是否有办法让slick2d可以被用户调整大小。(我已经研究了这个并且只发现了如何使程序在程序中可调整大小)
这是我的代码,并提前致谢。
package Main;
import States.Menu;
import States.Play;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
/**
*
* @author Kyle
*/
public class Lawu extends StateBasedGame{
public static final String gamename = "Lawu";
public static final int menu = 0;
public static final int play = 1;
public static int height=600,width=760;
public Lawu(String gamename)
{
super(gamename);
this.addState(new Menu(menu));
this.addState(new Play(play));
}
public static void main(String[] args) {
AppGameContainer appgc;
try{
appgc = new AppGameContainer(new Lawu(gamename),width, height, false);
appgc.start();
}
catch(SlickException e)
{
e.printStackTrace();
}
}
public void initStatesList(GameContainer gc) throws SlickException {
this.getState(menu).init(gc, this);
this.getState(play).init(gc, this);
gc.setIcon("res/Monster.png");
this.enterState(menu);
}
}
答案 0 :(得分:0)
在 appgc.start():
之前加上这个appgc.setResizable(true);
答案 1 :(得分:0)
您必须使用display.setResizable(boolean)
。