i'm a noob to this forum but i've been using processing for a year or so. can anyone shed some light on why i'm getting an ArrayIndexOutOfBoundsException error in this script? (i've not found any solutions online so far)
I'm trying to create create a script where each blob is added to the array on each cycle of the draw loop (rather than created all at once using a for loop), but i seem to have a problem iterating through the array to display the blobs in each frame.
thanks for any help!
j
//script to add objects to an array (or arraylist) in sequence depending on
//whether preceding item has given permission to create the next.
Blob[] blobList = new Blob[10];
int i = 0; //counter for blobList
void setup(){
size(200,200);
frameRate(1);
}
void draw(){
background(0); //clear screen
if(i < blobList.length){
blobList[i] = new Blob();
}
i++;
for(int j=0; j<i-1; j++){ //get an ArrayIndexOutOfBoundsException error here
blobList[j].display();
}
}
class Blob{
PVector loc;
boolean canGo;
int count;
Blob(){
loc = new PVector(random(width),random(height));
}