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

Report as inappropriate.

mik presents ...


Multi Level demo

Greenfoot now (since verison 2.1) has a new method:

Greenfoot.setWorld (World world)

This can be used to install a new world object to be shown in the main window. This is useful fro creating games with multiple levels (or other scenarios that change substantially at some stage).

This scenario is a small demo showing how this can be used. Just use the "Open in Greenfoot" button to download, and then look at the checkNextLevel() method in the Pengu class. It makes use of 'setWorld(..)' to go to a new level.

36886 views / 3471 in the last 7 days

15 votes | 0 in the last 7 days

Tags: demo with-source levels

This scenario is a member of: Scenario showcase

open in greenfoot
Your browser does not support the canvas tag.


How does it know its going to start from level1 ?? I mean where is the code that tell the world to start the game from the first level ??? Please let me know :) thanks


While you are developing, you can instantiate different levels interactively (by right-clicking your world subclass and selecting "new ..."). The world which you last instantiated interactively will be the one the scenario starts with.


Glad someone answered. I was trying to make another super class for my levels (subWorlds), since they all share stuff like background, but i faced some issue since they are all children of that class. I didn't know how to call them, so i make it simple, they are all subclasses of World. guess will try now to see how it works.


Hello I am creating a shooting game and i was wondering how to proceed to the next level once all the enemies are gone, thanks


this is such a bad game


I implemented this as a cheat to send the player into a blank room in my game, and it was working. However I was changing the layout of the room a bit and now the scenario freezes every time I use the cheat. I've tried changing the layout back to how it was before along with a multitude of other things, but it just won't work anymore. Does anyone know why?
@Entity1037 It would work better if you posted a discussion about this, with some code instead.
Thanks this really helped :)


When I go backward in the second level, it doesn't go to first


delete the world

See all comments

Want to leave a comment? You must first log in.

Who likes this?

Sonal data17 SullyFish joeschmoe Ariane BradH kiarocks Dreikäsehoch dangjavageek Locomotion15 webmessia mjrb4 rsouthard Evmorov drhorriblejr