I want my Object to change its Image when clicked on it. The name of the class is Profile, and the two images are "Tickbox.png" and "Tickboxtick.png". Greenfoot compiles the Code I got so far, but when I click on the Object, it doesn't change it's image.
I got this Code so far:
I'd be really grateful for you to help me with that problem as it's a programme I have to finish as quickly as possible.
private GreenfootImage tickbox;
private GreenfootImage tickboxtick;
public Profile()
{
tickbox = new GreenfootImage("Tickbox.png");
tickboxtick = new GreenfootImage("Tickboxtick.png");
}
public void act()
{
changeImage();
}
public void changeImage()
{ MouseInfo mouse = Greenfoot.getMouseInfo();
if(Greenfoot.mouseClicked(Profile.class)&& mouse.getButton()==1 )
{
if(getImage()==(tickbox))
{
setImage("Tickboxtick.png");
}
else
{
setImage("Tickbox.png");
}
}
}
