Save and load game profiles
There are many different ways to implement the save/restore functionality in a game. There is a spectrum of options in the solution space, with one end of the spectrum for a minimalist approach for save/restore philosophy, specifically a simple name/value pair approach, with values for persisting a high score or the current level number. LibGDX supports this natively through the Preferences
class in LibGDX that is modeled after preferences on Android. The other end of the save/restore functionality spectrum is a brute force approach where everything in-memory for the current game state is dumped to some binary format. This approach has severe drawbacks with save game sizes and also has a brittle state where one change in a class (patch update) can render previous saves useless. Our philosophy approach for the purpose of this book is one that adopts a little from both ends of the spectrum.
The primary class that will handle all of our serialization and deserialization...