I have a button which starts a game. When the mouse hovers over the button, I want it to change the image. The code works here but then changes back to image1 straight away. Is there a way i can make the image stay if the house is hovering over it.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Start here. * * @author (your name) * @version (a version number or a date) */ public class Start extends Actor { private GreenfootImage image1 = new GreenfootImage("dechrau.png"); private GreenfootImage image2 = new GreenfootImage ("dechrau2.png"); private int counterx = 0; /** * Act - do whatever the Start wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { if(Greenfoot.mouseMoved(this)){ setImage(image2); } else {setImage(image1); } if(Greenfoot.mouseClicked(this)) Greenfoot.setWorld(new CrabWorld()); } }