This site requires JavaScript, please enable it in your browser!
Greenfoot back
itssemu
itssemu wrote ...

2018/3/18

Why does this have an error at the "List" part of the code?

itssemu itssemu

2018/3/18

#
Hi there sorry to bother you again but this isnt working and I don't know why?
public class ShotInterfere extends Actor
{
    GifImage explosion = new GifImage("Steam-Explosion.gif");
    GreenfootImage imageOne;
    boolean notImageOne;
    public ShotInterfere()
    {
        List <GreenfootImage> images = explosion.getImages();
        imageOne = images.get(0);
        for(GreenfootImage img: images) 
        {
            img.scale(75, 75);
        }
        setImage(explosion.getCurrentImage());
    }
    public void act() 
    {
        setImage(explosion.getCurrentImage());
        if((getImage() != imageOne) != notImageOne)
        {
            notImageOne = !notImageOne;
            if(!notImageOne)
            {
                getWorld().removeObject(this);
            }
        }
    }    
}
danpost danpost

2018/3/18

#
When you get an error, you really need to specify what kind of error. Please do not just say it "have an error" without additional information about it. If you do not import the java.util.List class into the code of your class, then you must specify it in the line of code where you use the class:
java.util.List<GreenfootImage> images =  = explosion.getImages();
itssemu itssemu

2018/3/18

#
thanks this worked!
You need to login to post a reply.