NullPointerException with PImage Array
in
Programming Questions
•
2 years ago
Hi... a little confused here.
Im getting a NullPointerException when trying to call an Array variable into an image function.
- PImage Alex[];
- int count = 0;
- void setup() {
- size(800,800);
- background(0);
- PImage[] Alex = new PImage[5];
- Alex[0] = loadImage("Alex1.jpg");
- Alex[1] = loadImage("Alex2.jpg");
- Alex[2] = loadImage("Alex3.jpg");
- Alex[3] = loadImage("Alex4.jpg");
- Alex[4] = loadImage("Alex5.jpg");
- }
- void draw() {
- println(frameCount);
- }
- void mousePressed() {
- count++;
- println(count);
- image(Alex[count],0,0);
- }
I'm getting the NPE at line 25, but am getting the println output first.
If I don't include a draw(), then I dont get the NPE, but get no output, either onscreen or in my console.
I'm a little new to Arrays,so perhaps I am doing something wrong ??
1