1 2 3 4 5 6 | { hasStarted = true ; writeTitle(); Greenfoot.delay( 90 ); Greenfoot.setWorld( new Menu()); } |


1 2 3 4 5 6 | { hasStarted = true ; writeTitle(); Greenfoot.delay( 90 ); Greenfoot.setWorld( new Menu()); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 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 } } |
1 2 3 4 5 | 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 |
1 | addObject( new Curtain( null ), getWidth()/ 2 , getHeight()/ 2 ); |