To load my images I have decided ot use the class BufferedImage. To make things a little easier I have created a method which looks like this:
private BufferedImage loadImage(String path)
{
try
{
img = ImageIO.read(new File(path));
return img;
}catch (IOException e){}
return null;
}
Using this code does however output me an error (@ line: 15). The line on which this error (NullPointerException) appears looks like this:
g.drawImage(game.loadImage("/textures/dot.png"), 0, 0, null);
I am still learning this all, but I am pretty sure that the problem is related to my project settings since I have tried to load images on a bunch of different ways but the result was always the same.
This is my .classpath file:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="textures"/>
<classpathentry kind="con" path=". . ."/>
<classpathentry kind="output" path="bin"/>
</classpath>
I have created the folder “textures” with the help of Eclipse and set it as a project folder.
And yes, this folder does contain the file “dot.png”.
Thanks in advance!