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

2018/1/6

New Level

Echarch11 Echarch11

2018/1/6

#
Hi there. I'm looking to make a new level in my game. I was just wondering how to declare the new world and how to switch to that world once the first level is complete. To complete the level, the character has to kill all the enemies.
xbLank xbLank

2018/1/6

#
You can check if there are no Objects of the Enemies class left in the world (Check danposts post about that here). If thats the case you can load the new World like so:
Level2 world = new Level2();
Greenfoot.setWorld(world);
If you want to pass values between the levels (such as Health or Kills) then use the constructor (Check my first post here).
Echarch11 Echarch11

2018/1/6

#
ok thanks
Echarch11 Echarch11

2018/1/6

#
Would I put that code in the Level 2 Class?
xbLank xbLank

2018/1/6

#
No. You will have a condition like this in your Level 1 Class:
if(getObjects(Enemy.class).isEmpty())
{
    Level2 world = new Level2();
    Greenfoot.setWorld(world);
}
Echarch11 Echarch11

2018/1/6

#
ok
You need to login to post a reply.