How to make slick2d resizable

2019-09-07 06:29发布

Hey guys I was wondering if there was a way to make slick2d resizable by the user.(I have researched this and only found out how to make the program resizable within the program)

Here is my code and thanks in advance.

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);
    }
}

2条回答
老娘就宠你
2楼-- · 2019-09-07 06:38

You have to use display.setResizable(boolean).

查看更多
三岁会撩人
3楼-- · 2019-09-07 06:42

Put this before appgc.start():

appgc.setResizable(true);
查看更多
登录 后发表回答