Hi There!

After yesterday and creating functions that get called when tombstoning occurs, I needed a way to save the current state of the game, and the position of the player / enemies / particles / powerups etc. This seemed like a large challenge, and I’ve heard a lot about Serialization when it comes to fixing this problem. I’ve never really used Serialization before, but it seems to be the best thing to use to save state data, so here goes!

After searching through many web pages I found many articles talking about XML Serialization in C# and XNA, and the best place to store these files was in the IsolatedStorage area. I’m already storing a few simple settings in the IsolatedStorageSettings area, but they are just strings and now I needed to store an XML file. To store files in IsolatedStorage you need to use an IsolatedStorageFile and IsolatedStorageFileStreams. They work just like saving any other data on the PC, but instead of having free roam over where to store files on the PC, you have to use IsolatedStorage on the Windows Phone.

To serialize the data, I created a struct which holds all of the vital information, and filled it just before saving. I then created an XmlSerializer object and serialized this struct into isolated storage! With a simple struct which just holds the game state (enum) this worked fine and loaded perfectly! But when it came to serializing my own classes (the player class) it didn’t like it one bit. After trying a few things to get around this problem nothing seemed to work and after no time the Hour for today was over!

Tomorrow will be focusing on this serialization once again, and lets hope it gets sorted out asap! It’s a tedious task, but it needs to be done.