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

2013/3/10

Need Levelsplit HOW CAN I DO THIS??

Prish950 Prish950

2013/3/10

#
i want that i have 10 Worlds and every world is a level how can i add them and remove them that the new one appear. ??? PLEASE HELP!
danpost danpost

2013/3/10

#
The Greenfoot class has a 'setWorld' method that you can use to go from one world (or level) to the next. When you use that method the old world is removed automatically (unless you save a reference to it in the new world) and the new one will appear after the completion of the current method. To go from LevelOne to LevelTwo, in the LevelOne code:
Greenfoot.setWorld(new LevelTwo());
You can go from LevelOne to LevelOne by setting the world to LevelOne again, effectively re-starting the level.
Prish950 Prish950

2013/3/10

#
and where i have to write ??? in the level 1 world class or i need to create a levelsplitter world class and there type in all the set levels ??
danpost danpost

2013/3/10

#
If what you are saying is to create a superclass for all the world levels with two methods in it (one for determining the level to advance to and the other to determine the level to reset), then, yes, that is one viable possibility. It is probably the appropriate one also; otherwise, you would have to write those two methods in all the world level classes. An alternate possibility is to create an array of the level world classes in the initial world. Pass the array from world to world. When not resetting the world but advancing to the next, remove the first item from the array before passing it. Use the first item in the array for resetting and the second (if it exists) to advance. If you have an initial world that is not a level world, do not remove the first item before passing the array.
You need to login to post a reply.