FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   how do i do this in a for loop?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: how do i do this in a for loop?  (Read 845 times)
Master64

WWW Email
how do i do this in a for loop?
« on: Nov 15th, 2003, 9:34pm »

Hoi
 
I want to make a 100 objects with a for loop.
I have a working class.
I know Flash AS very well so i was thinking i would do this some thing like this:
 
Star ["star"+i] = new Star();
 
but it's not working.  
I have been looking in de reference for the right Syntax but with no luck.
 
i hope this is clear  
thanx M64
 
 


Jerronimo

WWW
Re: how do i do this in a for loop?
« Reply #1 on: Nov 16th, 2003, 2:45am »

probably need something like this:
 
Code:

 
// first, declare the array
int nItems = 100;
myClass items[] = new myClass[ nItems ];
 
void setup()
{
  // allocate all of the individual items
  for( int i=0 ; i<nItems ; i++ )
  {
    items[ i ] = new myClass();
  }
}
 
 
class myClass
{
 ...
}
 
 
 
Master64

WWW Email
Re: how do i do this in a for loop?
« Reply #2 on: Nov 16th, 2003, 11:37am »

Yeah that's it
 
 


Jerronimo

WWW
Re: how do i do this in a for loop?
« Reply #3 on: Nov 17th, 2003, 1:06am »

No prob.  
 
Pages: 1 

« Previous topic | Next topic »