I need to get the leaves on the left side of the image to change, not all the images.
From another actor class:
From Leaf actor class:
private void checkMouseClick()
{
if (Greenfoot.mouseClicked(null))
{
World world = getWorld();
List<Leaf> leaves = world.getObjects(Leaf.class);
for (Leaf leaf : leaves)
{
leaf.changeImage();
}
}
}
public class Leaf extends Actor
{
GreenfootImage img1 = new GreenfootImage("leaf-green.png");
GreenfootImage img2 = new GreenfootImage("leaf-brown.png");
public Leaf()
{
setImage(img1);
}
public void changeImage()
{
if (getImage() == img1)
{
setImage(img2);
}
else {
setImage(img1);
}
}
}

