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

2015/9/23

Save Game data

Vellyxenya Vellyxenya

2015/9/23

#
Hi, in my game, i want to add an option that allows me to leave the current game and continue it later, could you explain me how to save the game datas so that i can continue from where i've stopped please?
Super_Hippo Super_Hippo

2015/9/23

#
You can't save the world and resume it the next time you play. But you can save numbers and strings. For example the level which was reached. When starting the game, you need to get this data and build up the game with it. Use the UserInfo class.
Vellyxenya Vellyxenya

2015/9/23

#
I can't even save the world to go in another world and be right back after some seconds?
davmac davmac

2015/9/23

#
Sure, in that case you don't need to do anything special to save the world. Just keep a reference to it handy (in a variable of type World) then use Greenfoot.setWorld(...) to restore it when you're ready.
Vellyxenya Vellyxenya

2015/9/23

#
Something like:
1
World currentGame = getWorld();
?
danpost danpost

2015/9/23

#
Vellyxenya wrote...
Something like:
1
World currentGame = getWorld();
?
That would get a reference to the current world within a method of an Actor object. After (or when) the new world is created, that reference must be passed and saved in that new world so that you can return to the world later. This would need to be done before the method is exited from as the reference is local to the method in which it is acquired.
Vellyxenya Vellyxenya

2015/9/23

#
How can i pass and save a reference in another world pls?^^
danpost danpost

2015/9/23

#
Please supply the names of your worlds, specify which one is the main one and which one needs to keep a reference to the other. A brief description of what the worlds are for might also help (like: a game world, Welt class, temporarily going to a menu world, Menu class)
Vellyxenya Vellyxenya

2015/9/23

#
It's okay I managed to fix that, thank you! :D
You need to login to post a reply.