This site requires JavaScript, please enable it in your browser!
Greenfoot back
CreepingFuRbalL
CreepingFuRbalL wrote ...

2013/11/22

How to open a new level

CreepingFuRbalL CreepingFuRbalL

2013/11/22

#
How would you open a new world subclass to play once the objective has been beaten eg if all of a certain actor have been destroyed
Gevater_Tod4711 Gevater_Tod4711

2013/11/22

#
To check whether there are no more objects from a class you can use this code:
if (getWorld().getObjects(Enemy.class).isEmpty()) {
    //there are no more Enemy objects in the world;
}
If you add this code in a World subclass leave out the getWorld(). To set the world to a new world you can use the method Greenfoot.setWorld(World) e.g. like this:
if (getWorld().getObjects(Enemy.class).isEmpty()) {
    //there are no more enemys so you can start the next level;
    Greenfoot.setWorld(new Level2());//you can add every world subclass here;
}
You need to login to post a reply.