Here's my code. For some parts it works fine but for other's when it I say if(Greenfoot.mouseClicked(continueButton)) nothing happens. Am I missing something in it?
public class ContinueButton extends Actor
{
private GreenfootImage continueButton;
public void ContinueButton()
{
continueButton = new GreenfootImage("ContinueButton.png");
this.setImage(continueButton);
}
public void act()
{
if(Greenfoot.mouseClicked(this))
{
if(getWorld() instanceof ReadLetter)
{
//if the user is in world ReadLetter and the mouse is clicked on the continue button
//it sets the world to the next world
Greenfoot.setWorld(new BedRoom());
}
else if(getWorld() instanceof BedRoom)
{
/*If the user is in world BedRoom and the mouse is clicked on the continue button
*it removes the continue button and sets a new background. The game will wait until
*the user clicks on the note on the bed and sets the world to the next world*/
getWorld().setBackground("Dialogue2.png");
if(getWorld().getBackground().equals("Dialogue2.png"))
{
ContinueButton continueButton = new ContinueButton();
getWorld().removeObject(continueButton);
//If background is Dialogue2.png then remove the continue button
}
Note note = new Note();
getWorld().addObject(note,518,310);
if(Greenfoot.mouseClicked(note))
{
Greenfoot.setWorld(new NoteZoom());
}
}
else if(getWorld() instanceof NoteZoom)
{
Greenfoot.setWorld(new BedRoomTwo());
}
else if(getWorld() instanceof BedRoomTwo)
{
if(getWorld().getBackground().equals("PicturesZoomDialogue.png"))
{
if(Greenfoot.mouseClicked(this))
{
Greenfoot.setWorld(new River());
}
}
}
else if(getWorld() instanceof SuitCase)
{
getWorld().setBackground("SuitcaseDialogue2.png");
if(Greenfoot.mouseClicked(continueButton))
{
getWorld().setBackground("Suitcase.png");
getWorld().removeObject(this);
}
}
}
}
}

