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.
IndexProgramming Questions & HelpPrograms › Class constructor with a list
Page Index Toggle Pages: 1
Class constructor with a list (Read 626 times)
Class constructor with a list
Mar 22nd, 2009, 6:19pm
 
Hello everyOne !

I would like to know if it's possible to have a Pimage list in a class and if yes what's the syntax to declare the list in the class's constructor. Thank's
Re: Class constructor with a list
Reply #1 - Mar 22nd, 2009, 6:32pm
 
You mean like this:

Code:

class MyClass
{
PImage[] images;
MyClass()
{
images=new PImage[10];
}
}
Re: Class constructor with a list
Reply #2 - Mar 22nd, 2009, 6:50pm
 
No no

Something like that :

class MyClass{
PImage picture;

 MyClass(float, float, PImage[] ????){
    picture = ????;
   }
}

you see ?
Re: Class constructor with a list
Reply #3 - Mar 22nd, 2009, 8:23pm
 
You should have deleted the duplicate thread, I answered there and now we have information in two places, not cool...
Anyway, my answer there wasn't on the spot, so you can still delete it without remorse... Smiley

Code:
class StuffWithImages {
PImage[] pictures;

StuffWithImages(float x, float y, PImage[] someImages) {
pictures = someImages;
// With above, you have a reference to the original
// array. Not a problem in general, but if you need
// a copy, you can do:
picture = Arrays.copyOf(someImages, someImages.length);
}
}
Page Index Toggle Pages: 1