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

2013/11/2

Moving from World to World (i.e. through a door)

askgriff askgriff

2013/11/2

#
So I should know this -- but I want to have a world with some doors. When someone walks through a door on the right side of the screen, I want to switch worlds and have them enter on the left side of the screen in the new world. Is there an easy way? :)
askgriff askgriff

2013/11/2

#
Just looking at some graphics online and saw this -- and thought it might help explain what I'm trying to do:
askgriff askgriff

2013/11/2

#
Or on a similar note, having one world (or screen) connecting to another and scrolling. For example:
danpost danpost

2013/11/2

#
So ... which way would you like to proceed? Both are probably going to take a little doing.
askgriff askgriff

2013/11/3

#
We'll start with the easiest: I'm assuming the multiple "worlds" and then when you move into a door, it changes the world.
askgriff askgriff

2013/11/3

#
Actually -- we could use the "atWorldEdge" method. So if it hits the world edge on the right, it goes to world 2. If it hits the edge on the top, it goes to world 3. etc.
askgriff askgriff

2013/11/3

#
I'm thinking I could use something as simple as:
Greenfoot.setWorld(new Ground2());
But I don't know how to get the doors to work with that.
danpost danpost

2013/11/3

#
If using doors and the doors are Actor objects, you can add an instance field to hold the world to set when the player intersects it. Each level would set its doors to the appropriate levels to proceed to. If using the world edges, you will need one or two static fields to track the 'coordinates' of the current world. I could upload a demo of this method if you wish.
askgriff askgriff

2013/11/3

#
I would sincerely appreciate that, danpost. Thank you.
danpost danpost

2013/11/4

#
It is here.
You need to login to post a reply.