Java - Libgdx : Save & Load a screen

615 Views Asked by At

my game is about stories, you make choices and it will lead you to other screen like a novel in which you are the hero, I realised I need a save system, I want to save the last screen a player was on and load it when he click on load button in main menu :

like this

I found the class FileHandle but I don't know how to link it with my gamescreens. How am I supposed to code "save the last screen the player is on" and "load the last screen the player was on"

Thanks for your knowledge sharing

2

There are 2 best solutions below

3
Matthew Tory On

You should have a look at the libGDX wiki.

Specifically:

File Handling

and

Preferences

If you only need to save the last page the user was on, Preferences might be your best option. You can easily save primitive data types, such as the index of the last screen, or the title, or however you have your content set up.

1
Gokul Sreenivasan On

use the Preference to save the game state in libgdx . which will store the data in devices internal memory. by using the preference you can save anything say example the score of the player. I have answered for the same kind of question in below link .please go through it once. I hope you will get the solution. Creating an Android save file on the local storage of the device?