0

嘿伙计们,我想知道是否有一种方法可以让用户调整 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);
    }
}
4

2 回答 2

0

把它放在appgc.start()之前:

appgc.setResizable(true);
于 2013-04-09T21:33:37.467 回答
0

你必须使用display.setResizable(boolean).

于 2017-02-17T19:24:24.750 回答