I am trying to make different things happen in different worlds. My current Code is:
this always fails once it switches. how do i make this work?
public World whichworld; public Button(World world) { whichworld = world; } /** * Act - do whatever the Button wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { SpaceWorld.started = true; if(Greenfoot.mouseClicked(this) && whichworld == getWorld()) { Greenfoot.setWorld(new CircutWorld()); } else if(Greenfoot.mouseClicked(this) && whichworld == getWorld()) Greenfoot.setWorld(new SpaceWorld()); if(whichworld == getWorld()) { GreenfootImage img = new GreenfootImage("Go to Work!",12,Color.black,Color.blue); setImage(img); } else if(whichworld == getWorld()) { GreenfootImage img = new GreenfootImage("Back to Space!",12,Color.black,Color.green); setImage(img); } }