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

Report as inappropriate.

mik
mik presents ...

2011/6/9

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.

37350 views / 74 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.
mikmik

2011/11/19

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.
mjoraidmjoraid

2011/11/19

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.
BradHBradH

2012/10/24

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
HappyHarryHappyHarry

2013/3/18

this is such a bad game
Entity1037Entity1037

2013/6/10

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 :)
VenbhaVenbha

2017/9/6

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

2020/4/9

delete the world
ALMEIDAALMEIDA

2024/7/26

acho que deveria ter mais fases

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