Код: Выделить всё
package tile;
import java.awt.Graphics2D;
import java.io.IOException;
import javax.imageio.ImageIO;
import main.gamePanel;
public class TileManager {
gamePanel gp;
Tile[] tile;
public TileManager(gamePanel gp) {
this.gp = gp;
tile = new Tile[10];
}
public void getTileImage() {
try {
tile[0] = new Tile();
tile[0].image = ImageIO.read(
getClass().getResourceAsStream("/tiles/grass.png")
);
tile[1] = new Tile();
tile[1].image = ImageIO.read(
getClass().getResourceAsStream("/tiles/wall.png")
);
tile[2] = new Tile();
tile[2].image = ImageIO.read(
getClass().getResourceAsStream("/tiles/water.png")
);
} catch (IOException e) {
e.printStackTrace();
}
}
public void draw(Graphics2D g2) {
g2.drawImage(tile[0].image, 48, 48, gp.tileSize, gp.tileSize, null);
}
}
Код: Выделить всё
public void update() {
player.update();
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
tileManager.draw(g2);
player.draw(g2);
g2.dispose();
}
Исключение в потоке "awt-eventqueue-0" java.lang.nullpointerexception: не удается чтение полевого изображения, потому что «this.tile [0] null < /p>
< /blockquote>
я наверняка то же самое.
Подробнее здесь: https://stackoverflow.com/questions/797 ... lang-nullp
Мобильная версия