We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
clear an array (Read 206 times)
clear an array
Nov 8th, 2008, 10:44pm
 
hello

i want to clear an array after i released the mouse button. but how can i do this?

// limited size to 100 clicks
int[] xpos;
int[] ypos;
int clickCount;

void setup()  
{
 size(200, 200);

 xpos = new int[ 10 ];
 ypos = new int[ 10 ];
 clickCount = 0;
}

void draw()  
{
 
 if (mousePressed == true) {
     //if( clickCount >= 100 )
     //return;
     xpos[clickCount] = mouseX;
     ypos[clickCount] = mouseY;
     clickCount++;
 }
 // if mousereleased clear the array

 for (int i = 0; i < 10; i++) {
     ellipse(xpos[i], ypos[i], 60, 60);
 }
   
}
Re: clear an array
Reply #1 - Nov 8th, 2008, 11:09pm
 
The fastest way is probably to use Arrays.fill().
Page Index Toggle Pages: 1