简体   繁体   English

如何修复Slick2d中的图像重复?

[英]How do you fix image duplication in Slick2d?

There is a glitch with slick2d. slick2d有一个小故障。 The pictures I make it draw on the window duplicates. 我在窗口上绘制的图片重复出现。 I am on a windows 7 computer running eclipse. 我在运行Eclipse的Windows 7计算机上。 I am using paint.net for my graphics this is what it looks like: 我正在为我的图形使用paint.net,它是这样的:

I would have an image of it but I can't yet, sorry. 我想要一张它的图片,但我还不能,抱歉。

This is my image code: 这是我的图像代码:

    /**
 * Images
 */

// Title

Image title;
public static int titleX = 100;
public static int titleY = 500;

// Play Button

Image play;
public static int playX = 210;
public static int playY = 500;

// Options Button

Image options;
public static int optionsX = 310;
public static int optionsY = 500;

// Quit Button

Image quit;
public static int quitX = 410;
public static int quitY = 500;

    public void init(GameContainer Gc, StateBasedGame Sbg)
        throws SlickException {

    /**
     * Images
     */

    title = new Image("gfx/main_menu/title/new_title.png");
    play = new Image("gfx/main_menu/buttons/play_button.png");
    options = new Image("gfx/main_menu/buttons/options_button.png");
    quit = new Image("gfx/main_menu/buttons/quit_button.png");
}

    public void render(GameContainer Gc, StateBasedGame Sbg, Graphics G)
        throws SlickException {

    /**
     * Background
     */

    G.setColor(Color.white);
    G.fillRect(0, 0, w*s, h*s);

    /**
     * Images
     */

    title.draw(titleY*s,titleX*s);
    title.draw(playY*s,playX*s);
    title.draw(optionsY*s,optionsX*s);
    title.draw(quitY*s,quitX*s);
}

您正在绘制图像“标题”四次,而从未调用其他图像(播放,选项和退出)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM