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

2012/7/4

moving onto next level

jcoode jcoode

2012/7/4

#
I am making a game that has different levels. i want my game to move to a different world when my actor 'man' reaches the door. what code do i use?
danpost danpost

2012/7/4

#
What is the name of your actor 'man' class and your 'door' class? What is the name of the world you are in and the world you are going to? What code have you tried so far? Will there be only one door present, or more? If more, will only one be open to the new world, or would the other lead to a different world? Basically, you should not just ask what code you should use without giving exactly how and what you intend, as well as what it is actually doing at the moment and why and how it is not doing what you want. Supplying some code helps to incorporate any changes more suitably (as well as more productively).
erdelf erdelf

2012/7/4

#
In the act of door:
if(getOneIntersectingObject(man.class) != null) // change man to the name of your char
{
    Greenfoot.setWorld(new Level2); // change Level2 with the name of the second world
}
danpost danpost

2012/7/4

#
Line 3 should be
Greenfoot.setWorld(new Level2());
with the '( )' after the World name.
jcoode jcoode

2012/7/4

#
thanks. it works now
You need to login to post a reply.