提问人:Martin Parunev 提问时间:4/6/2022 最后编辑:hfontanezMartin Parunev 更新时间:4/6/2022 访问量:60
IllegalArgumentException不确定我是否正确编写了数组
IllegalArgumentException not sure if I wrote the array right
问:
gamePanel gp;
Tile[] tile;
public tileManager(gamePanel gp){
this.gp = gp;
tile = new Tile[10]; // this means we're going to create 10 types of tiles (water, grass, water, sand, etc...)
getTileImage();
}
public void getTileImage(){
try{
tile[0] = new Tile();
tile[0].image = ImageIO.read(requireNonNull(getClass().getResourceAsStream("res/tiles/grass.png")));
tile[1] = new Tile();
tile[1].image = ImageIO.read(requireNonNull(getClass().getResourceAsStream("/tiles/wall.png")));
tile[2] = new Tile();
tile[2].image = ImageIO.read(requireNonNull(getClass().getResourceAsStream("/tiles/water.png")));
} catch (IOException e) {
e.printStackTrace();
}
}
public void draw(Graphics2D g2){
g2.drawImage(tile[0].image,0, 0, gp.tileSize, gp.tileSize, null);
}
}
所以我正在尝试在我的游戏中添加瓷砖,但我不明白为什么会出现错误?我在网上找到了这个,所以任何如何解决这个问题的建议将不胜感激!
答: 暂无答案
评论
IllegalArgumentException
null
requireNonNull
grass.png
null