Array Isn't Detected In Parameter

I am trying to make an animation system to display images with a certain frame rate. While attempting to pass the function an array, it said I had not created an array or variable with that name. I tried adding square brackets to no avail. I also tried changing some syntax in the declaration of the array, declaring the PImages then sending them to the array and even putting the array in different scopes.


PImage idleDev[] = {loadImage("IdleDev1.png"), loadImage("IdleDev2.png")};

Use In Method:

animation(x, y, (int)frameRate/2, idleDev, 2, (float)playerWidth, (float)playerHeight);

Any ideas to fix this? It has been pissing me off for the past hour!

Without more of your code to work from, I would guess this is a scope problem.
If idleDev is declared as-is in setup() then draw() would not be able to see it.

You would need two parts to make everything happy.

// global variable (outside any function)
PImage idleDev[];


// inside setup()
idleDev = new PImage[]{loadImage("moon.bmp"), loadImage("smallmoon.bmp")};

Also a good idea to test inside draw() that idleDev != null before calling animation().


Thanks, I’ll go try that out now!

It appears to have worked, now I can finally continue, Thank You!