[英]Slick2d background
I am trying to render a background image in my Slick2d window. 我正在尝试在Slick2d窗口中渲染背景图像。 However, it's not rendering.
但是,它不是渲染。 What's wrong?
怎么了?
This is the first part of my main class 这是我主要课程的第一部分
public class SimpleGame extends BasicGame{
Image land = null;
public SimpleGame()
{
super("Slick2DPath2Glory - SimpleGame");
}
@Override
public void init(GameContainer gc) throws SlickException {
land = new Image("bg.jpg");
land.draw(0,0);
}
Here's the root tree http://billedeupload.dk/images/4J5CQ.png 这是根树http://billedeupload.dk/images/4J5CQ.png
You should do all the rendering in the render() method instead of the init() method. 您应该在render()方法而不是init()方法中进行所有渲染。 So something like this:
所以像这样:
@Override
public void init(GameContainer gc) throws SlickException {
land = new Image("bg.jpg");
}
@Override
public void render(GameContainer gc, StateBasedGame sb, Graphics g) throws SlickException {
g.drawImage(land, 0, 0);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.