/*********************************** *TODO - Images are getting called * *more than once each turn of draw.* *Will work out at later date. * * * *Next step - Turn into class! * ***********************************/ //Initialising various variables. String imageDirectory="images"; String[] imageList; int num=0; //PImage[] loadedImages; ImagePlayer playImage; void setup(){ size(300,300); background(0); playImage = new ImagePlayer(imageDirectory, num); /*The next line is a bit convoluted so will work out if there's a better way to do it.*/ //imageDir=sketchPath+"/data/"+localImageList; playImage.setFileDirectory(); //Create an initial array of Strings of the images in the image directory! //imageList=fileLoader(imageDir); playImage.imageLoader(); //Create a PImage array of images from the fileLoader function //loadedImages=imageLoader(imageList); } void draw(){ frameRate(5); playImage.imagePlayer(); } /*A function that if i or I is pressed, re-searches directory and loads them into a new PImage. This updates the images displayed for the imagePlayer function.*/ void keyPressed(){ if((key=='i')||(key=='I')){ playImage.num=0; playImage.setFileDirectory(); playImage.imageLoader(); /*Strangely figured this part out at 02.00 in the morning *whilst reading an unrelated subject in a processing book. *Resets num so that it is not out of range if images *are removed. Otherwise array out of bounds *exception occurs! Argh! */ } }