如何使 slick2d 可调整大小 [英] How to make slick2d resizable

查看:61
本文介绍了如何使 slick2d 可调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我想知道是否有办法让用户可以调整 slick2d 的大小.(我已经研究过这个并且只发现了如何在程序中调整程序大小)

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

推荐答案

把这个放在 appgc.start() 之前:

appgc.setResizable(true);

这篇关于如何使 slick2d 可调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆