That is a less than ideal solution though. Not only are you creating a completely new image each time you check, but you also have to compare the images pixel by pixel to see if they are equal.


import java.util.ArrayList; static ArrayList<GreenfootImage> images = new ArrayList<GreenfootImage>(); private int frame; static public void initialize() { images.add(new GreenfootImage("image 1 name")); images.add(new GreenfootImage("image 2 name")); ... } public void act() { frame ++; if(frame >= images.size()) { frame = 0; } setImage(images.get(frame)); }
(Classname).initialize();