So I've been tinkering around with Greenfoot. More specifically, I've been trying to grasp the concept of how I can animate stuff by image shifting. Here is a code for one animation I've been trying to do. When I run it, the images don't seem to change an is stuck at the first image only.Also, I've taken java before in Highschool but the IDE we used was Netbeans so Greenfoot is kind of a haze to me atm.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Lyn here. * * @author (your name) * @version (a version number or a date) */ public class Lyn extends Actor { GreenfootImage image0,image1,image2,image3,image4,image5,image6,image7,image8,image9,image10,image11,image12,image13,image14,image15,image16,image17,image18,image19,image20,image21,image22,image23,image24,image25; /** * Act - do whatever the Lyn wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public Lyn() { image0=new GreenfootImage("0.png"); image1=new GreenfootImage("1.png"); image2=new GreenfootImage("2.png"); image3=new GreenfootImage("3.png"); image4=new GreenfootImage("4.png"); image5=new GreenfootImage("5.png"); image6=new GreenfootImage("6.png"); image7=new GreenfootImage("7.png"); image8=new GreenfootImage("8.png"); image9=new GreenfootImage("9.png"); image10=new GreenfootImage("10.png"); image11=new GreenfootImage("11.png"); image12=new GreenfootImage("12.png"); image13=new GreenfootImage("13.png"); image14=new GreenfootImage("14.png"); image15=new GreenfootImage("15.png"); image16=new GreenfootImage("16.png"); image17=new GreenfootImage("17.png"); image18=new GreenfootImage("18.png"); image19=new GreenfootImage("19.png"); image20=new GreenfootImage("20.png"); image21=new GreenfootImage("21.png"); image22=new GreenfootImage("22.png"); image23=new GreenfootImage("23.png"); image24=new GreenfootImage("24.png"); image25=new GreenfootImage("25.png"); setImage(image0); } public void act() { animation(); } public void animation() { if(getImage() == image0) setImage(image1); if(getImage() == image1) setImage(image2); if(getImage() == image2) setImage(image3); if(getImage() == image3) setImage(image4); if(getImage() == image4) setImage(image5); if(getImage() == image5) setImage(image6); if(getImage() == image6) setImage(image7); if(getImage() == image7) setImage(image8); if(getImage() == image8) setImage(image9); if(getImage() == image9) setImage(image10); if(getImage() == image10) setImage(image11); if(getImage() == image11) setImage(image12); if(getImage() == image12) setImage(image13); if(getImage() == image13) setImage(image14); if(getImage() == image14) setImage(image15); if(getImage() == image15) setImage(image16); if(getImage() == image16) setImage(image17); if(getImage() == image17) setImage(image18); if(getImage() == image18) setImage(image19); if(getImage() == image19) setImage(image20); if(getImage() == image20) setImage(image21); if(getImage() == image21) setImage(image22); if(getImage() == image22) setImage(image23); if(getImage() == image23) setImage(image24); if(getImage() == image24) setImage(image25); if(getImage() == image25) setImage(image0); } }