NullPointerException in Minim and loading images
in
Core Library Questions
•
6 months ago
Making a tilemap for a programming class and it needs to be accompanied by background music. Unfortunately this error pops up and i have yet to find the cause of why....
The file "cave.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
The file "cave1.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
The file "cave2.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
The file "cave3.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
The file "cave4.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
The file "cavet1.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
The file "cavet2.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
The file "dirtcave2.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
==== JavaSound Minim Error ====
==== Failed to get method sketchPath from file loading object provided!
==== null
==== File recording will be disabled.
==== JavaSound Minim Error ====
==== Failed to get method createInput from the file loading object provided!
==== null
==== File loading will be disabled.
Exception in thread "Animation Thread" java.lang.NullPointerException
at ddf.minim.Minim.<init>(Unknown Source)
at Brogan_Assign_8_2.setup(Brogan_Assign_8_2.java:50)
at processing.core.PApplet.handleDraw(PApplet.java:2117)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Thread.java:662)
Here is the original code
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
{PImage img0, img1, img2, img3, img4, img5, img6, img7;
img0= loadImage("cave.png");
img1 = loadImage("cave1.png");
img2 = loadImage("cave2.png");
img3 = loadImage("cave3.png");
img4 = loadImage("cave4.png");
img5 = loadImage("cavet1.png");
img6 = loadImage("cavet2.png");
img7 = loadImage("dirtcave2.png");}
Minim minim;
AudioPlayer player;
String[] tileMap;
int TILE_SIZE = 16;
PImage[] tiles = new PImage[8];
void setup(){
minim = new Minim(player);
player= minim.loadFile(dataPath("cavesound1.wav"));
player.play();
tileMap = loadStrings("tilemap1.txt");
size(TILE_SIZE*tileMap[0].length(), TILE_SIZE*tileMap.length);
tiles[0]=loadImage("dirt.png");
tiles[1]=loadImage("cave.png");
tiles[2]=loadImage("cave1.png");
tiles[3]=loadImage("cave2.png");
tiles[4]=loadImage("cave3.png");
tiles[5]=loadImage("cave4.png");
tiles[6]=loadImage("cavet1.png");
tiles[7]=loadImage("cavet2.png");
println(tileMap);
}
void draw(){
for(int i=0; i<tileMap.length;i++){
for(int j=0; j<tileMap[i].length();j++){
int tileValue=Character.getNumericValue(tileMap[i].charAt(j));
image(tiles[tileValue], j*TILE_SIZE,i*TILE_SIZE,TILE_SIZE,TILE_SIZE);
}}}
void stop(){
minim.stop();
player.close();
super.stop();
}
I have highlighted the area where the error occurs. any advice or help would be greatly appreciated.
1