Sprite Animation

edited December 2015 in Programming Questions

Hi, i am kinda new to programming and processing and I am trying to create an animated sprite. I cannot make use of libraries. Underneath u can see my code, it loads the first image but it doesn't load the second nor the 3rd and forth though i put it in a loop. Please help!

PImage img1, img2, img3, img4; PImage [] imageArray = new PImage [4];

PImage img1, img2, img3, img4;
PImage [] imageArray = new PImage [4];

void setup(){
 size(400,400);
 background(150,150,150);
  
 //img1 = loadImage("img1.jpg");
 //img2 = loadImage("img2.jpg");
 //img3 = loadImage("img3.jpg");
 //img4 = loadImage("img4.jpg");
  
 imageArray[0] = loadImage("img1.jpg");
 imageArray[1] = loadImage("img2.jpg");
 imageArray[2] = loadImage("img3.jpg");
 imageArray[3] = loadImage("img4.jpg");
}

void draw(){ 
 for(int i = 0; i < imageArray.length; i++){
   image(imageArray[i], 200, 200);
   delay(10);
   if (i == 4){
     i = 0;
   }
 }
}

Answers

Sign In or Register to comment.