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

2013/2/13

Level changing issues :(

Draymothisk Draymothisk

2013/2/13

#
I need the stats (Health, score, and lives) of my main character (Guy) to transfer from world to world with him, but they get reset when I delete him from the world. So, I though that it would be better for the world itself to have stats, and they just increase/decrease when Guy gets points and such. Anyways, is there a way to pass parameters or integers between worlds? Or is there a better way to do all of this? I just need the score and health to carry over to the next world without resetting. Any help? :)
danpost danpost

2013/2/13

#
If you had increase/decrease/set methods, then you can use the 'set' methods for stats (Health, score, and lives) to 'pass' the information to the new world. For example, just to show the idea:
Level2 level2 = new Level2(guy);
level2.setLives(getLives());
level2.setHealth(getHealth());
level2.setScore(getScore());
Greenfoot.setWorld(level2);
You need to login to post a reply.