Hi, I'm new to greenfoot and i have no clue how to make my lady bug change image when it hits the apple. I have been trying to figure out the solution by my self and some forum search but so far no luck. Any ways here is what my ladybug code looks like.
public class Ladybug extends Actor { public int applecounter; GreenfootSound eating = new GreenfootSound("eating.mp3"); //GreenfootSound GamveOver = new GreenfootSound("GamveOver.mp3"); private GreenfootImage image1; private GreenfootImage image2; /** * Act - do whatever the Ladybug wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { if (Greenfoot.isKeyDown("w")) { MouseInfo m = Greenfoot.getMouseInfo(); if (m != null) { turnTowards(m.getX(), m.getY()); move(4); Actor Apple = getOneObjectAtOffset(0, 0, Apple.class); if(Apple !=null) { getWorld() .removeObject(Apple); Greenfoot.playSound("eating.mp3"); applecounter++; if (applecounter ==7) { //Greenfoot.stop(); World world = getWorld(); if (world !=null) { world.removeObjects(world.getObjects(null)); world.addObject(new GameOver(), world.getWidth()/2, world.getHeight()/2); } } } } } } public void image() { image1 = new GreenfootImage("ladybug1.png"); image2 = new GreenfootImage("ladybug2.png"); } }