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

2012/1/17

How to transition to new level

Blight Blight

2012/1/17

#
Hi, I'm creating a platform game like super mario, but now I'm kinda stuck. At the end of the first level, I want to start the 2nd one when the user touches a door. But I really have no clue at all how to switch to a 2nd level. I want to change the background, but keep the score and lives the user has. Anyone got any suggestions? Thanks in advance.
stevenGrohe stevenGrohe

2012/1/17

#
you can save the levels as a string for example, and read them out, when the next level should appear. example: " 000000000000000000000000000000000000 000000000000000000000000000000000000 000000000000000000000000000000000000 000000000000000000000000000000000000 000000000000000000000000000000000000 000000000000000000000000000000000000 000000000000000000000000000000000000 000000020000003000000003000000300000 111111000111111111111111111111111111 " For this example every "0" means theres nothing, every "1" menas there´s normal ground, "2" menas there´s a moving platform, every "3" means there´s an enemy.
MikeReilly22 MikeReilly22

2012/1/18

#
For any new level, you can create a method in your world that removes all objects, then adds new background, new objects, etc. I would just keep any data about your game in a variable held by the world. You may even keep the score and data in some type of scorekeeper object, but be careful to remove everything but that one, or save it on the side while you wipe everything else out.
davmac davmac

2012/1/18

#
Blight, if you need more help, you should post some code to show what you have and what you're having trouble with. The question is way too general otherwise.
You need to login to post a reply.