我在java中制作游戏,涉及将图像绘制到帧中。当我尝试绘制图像时,出现以下错误:
java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(ImageIO.java:1348)
at main.Game.<init>(Game.java:57)
at main.Game.main(Game.java:319)
为什么我会这样?这是我访问文件的区域的代码:
try {
playerImage = ImageIO.read(this.getClass().getResourceAsStream("resources/player.png"));
bulletImage = ImageIO.read(this.getClass().getResourceAsStream("resources/bullet.png"));
enemyImage = ImageIO.read(this.getClass().getResourceAsStream("resources/enemy.png"));
highScoreReader = new BufferedReader(new FileReader("/files/HIGH_SCORE.txt"));
highScoreWriter = new BufferedWriter(new FileWriter("/files/HIGH_SCORE.txt"));
} catch (Exception e) {
e.printStackTrace();
}
以下是文件目录的图片:
我编目的目录错了吗?我没有正确抓取图像吗?
答案 0 :(得分:1)
是“s”,你有“resour'C'es”,文件夹是“resour'S'es”
答案 1 :(得分:0)
您的资源文件夹名为resourses
,但您的代码是从"resources/player.png"
调用的。