我需要获取游戏面板的当前Xpos和Ypos来制作它的屏幕截图,我正在使用Slick2D库,我知道如何获得宽度和高度,但坚持获得Xpos和Ypos。 我在这里如何实现渲染方法:
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
BufferedImage image = null;
try {
image = new Robot().createScreenCapture(new Rectangle(0,0,gc.getWidth(),gc.getHeight()));
}
catch (HeadlessException e1) { e1.printStackTrace(); }
catch (AWTException e1) { e1.printStackTrace(); }
try {
ImageIO.write(image, "png", new File("res/screenshot.png"));
} catch (IOException e) { e.printStackTrace(); }
Image SS=new Image("res/screenshot.png");
g.drawImage(SS, 0, 0);
g.drawString("Game Paused !", 100, 100);
}
我需要让Xpos和Ypos将它们放在矩形构造函数
中