I'm trying to create a function has an array of images. However, I keep getting an error. Is it possible to put an array inside a function? If so, how do I do it correctly? If not, what is another way to create a function that has images in it?
"error message: the method image (PImage,float,float,float,float) in the type PApplet is not applicable for the arguments(PImage[], float,float,int,int)"
void monument(PImage[] img, float x, float y, int sz) {
img = new PImage[10];
for ( int i = 0; i< img.length; i++ ) {
img[i] = loadImage( i + ".jpg" );
}
if (dist(x, y, mouseX, mouseY) < sz/2) {
if (mousePressed) {
cursor(MOVE);
x = lerp(x, mouseX, 0.2);
y = lerp(y, mouseY, 0.2);
} else {
cursor(HAND);
}
cursor(ARROW);
}
image(img, x, y, sz, sz);
Your function above is completely outta touch on how animation is done in Processing! :-??
There are things which should be done in setup() at the top, and the rest in draw() and event functions! [..]
Anyways, the error there is about passing an Array w/o specifying which index to use from it.
Answers
Would be helpful if you posted some code and told us what error messages you are getting.
"error message: the method image (PImage,float,float,float,float) in the type PApplet is not applicable for the arguments(PImage[], float,float,int,int)"
}
Your function above is completely outta touch on how animation is done in Processing! :-??
There are things which should be done in setup() at the top, and the rest in draw() and event functions! [..]
Anyways, the error there is about passing an Array w/o specifying which index to use from it.
As GoToLoop pointed out there are several problems here. This might get you started, but you can find more tutorials on the wiki :