{ hasStarted = true; writeTitle(); Greenfoot.delay(90); Greenfoot.setWorld(new Menu()); }
{ hasStarted = true; writeTitle(); Greenfoot.delay(90); Greenfoot.setWorld(new Menu()); }
import greenfoot.*; public class Curtain extends Actor { private int transVal; private int direction; World nextWorld; public Curtain(World inWorld) { nextWorld = inWorld; if (nextWorld == null) direction = -4; else direction = 4; } public void addedToWorld(World world) { setImage(new GreenfootImage(world.getWidth(), world.getHeight())); getImage().fill(); // black is default color for new GreenfootImages } public void act() { transVal = (transVal+direction+256)%256; // update value if (transVal == 0) // check value to see if we are done yet { if (nextWorld == null) getWorld().removeObject(this); // for new world else Greenfoot.setWorld(nextWorld); // for old world } else getImage().setTransparency(transVal); // for when not done yet } }
World world2 = new World2(); // create using name of your new world Curtain curtain = new Curtain(world2); // create curtain object int x = getWorld().getWidth()/2; int y = getWorld().getHeight()/2; addObject(curtain, x, y); // add curtain into world
addObject(new Curtain(null), getWidth()/2, getHeight()/2);