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 & HelpSyntax Questions › Loading a bunch of images
Page Index Toggle Pages: 1
Loading a bunch of images (Read 294 times)
Loading a bunch of images
Jul 6th, 2008, 1:20pm
 
I want to load some pictures called 0,1,2,3,4,5. I wrote this code:

PImage[] img = new PImage[6];
String[] name = new String[6];

void setup() {
 size(500, 500, P3D);

 name[0] = "0.jpg";
 name[1] = "1.jpg";
 name[2] = "2.jpg";
 name[3] = "3.jpg";
 name[4] = "4.jpg";
 name[5] = "5.jpg";
 
for (int i = 0; i < 6; i += 1){
img[i] = loadImage(name[i]);  
}
}

Is it possible to relate the index i directly to the name of the pictures? Or is it necessary to work with the String class?
Re: Loading a bunch of images
Reply #1 - Jul 6th, 2008, 1:28pm
 
You can do:

Code:
PImage[] img = new PImage[6];

void setup() {
size(500, 500, P3D);

for (int i = 0; i < 6; i += 1){
img[i] = loadImage(i+".jpg");
}
}
Page Index Toggle Pages: 1