use an ArrayList
How To
Here is an arraylist, you want this before setup()
ArrayList<PVector> listMousePositions = new ArrayList<PVector>();
To add to the arraylist (this could be in the function mousePressed()
):
listMousePositions .add(new PVector(mouseX,mouseY));
Read value
PVector pv = listMousePositions.get(2);
display all:
for(PVector pv : listMousePositions ) {
point (pv.x,pv.y);
}
OR
for(int i=0; i<listMousePositions.size()-2; ++) {
PVector pv1 = listMousePositions.get(i);
PVector pv2 = listMousePositions.get(i+1);
line (pv1.x,pv1.y,
pv2.x,pv2.y );
}
Set value
listMousePositions.set(int, new PVector(mouseX,mouseY));
(text from the forum)
Chrisir