sohxuanhong
YaBB Newbies
Offline
Posts: 6
Problem understanding array
Nov 9th , 2008, 4:01pm
I got 2 problem and really in need of help to solve it. 1. Is there any way that I can call files directly from the data folder..? because after i look through some example but i totally can't understand. =x 2. I am trying to write a array which i can load mutiple level and create a loading of random files. I know my problem is the code i wrote on the 1st line, but I think I wrote it wrongly that's why it doesn't work out. Can anyone please tell me my mistake. //Problem in loading the ImageNO array PImage BGImg [int(new ImageNO = 0)]; String BGImg1FileNames[] = { "levelOne/0.jpg", "levelOne/1.jpg", "levelOne/2.jpg", "levelOne/3.jpg", "levelOne/4.jpg" }; String BGImg2FileNames[] = { "levelTwo/0.jpg", "levelTwo/1.jpg", "levelTwo/2.jpg", "levelTwo/3.jpg" }; String BGImg3FileNames[] = { "levelThree/0.jpg", "levelThree/1.jpg", "levelThree/2.jpg", "levelThree/3.jpg" }; //retrive Imageno. lenght int TOTAL_IMAGES = BGImg1FileNames.length; int TOTAL_IMAGES2 = BGImg2FileNames.length; int TOTAL_IMAGES3 = BGImg3FileNames.length; //image loading array PImage[] BGCountImg = new PImage[TOTAL_IMAGES]; PImage[] BG2CountImg = new PImage[TOTAL_IMAGES2]; PImage[] BG3CountImg = new PImage[TOTAL_IMAGES3]; void setup() { size(1024,768); for (int i = 1; i<TOTAL_IMAGES; i++){ println("loading img "+i); BGCountImg[i] = loadImage(BGImg1FileNames[i]); //println("timer count img" + timerImgFileNames[i]); } for (int j = 1; j<TOTAL_IMAGES2; j++){ //println("loading img "+i); BG2CountImg[j] = loadImage(BGImg2FileNames[j]); } for (int k = 1; k<TOTAL_IMAGES3; k++){ //println("loading img "+i); BG2CountImg[k] = loadImage(BGImg3FileNames[k]); } BGImg[1] = BGCountImg[int(random(TOTAL_IMAGES))]; BGImg[2] = BG2CountImg[int(random(TOTAL_IMAGES2))]; BGImg[3] = BG3CountImg[int(random(TOTAL_IMAGES3))]; } void draw() { image(BGImg[ImageNo],0,0); println("ImageNO" + ImageNO); } void mouseReleased() { ImageNO = ImageNO+1 ; }