currently I' using XNA 4.0 Game Studio and the Window Game Statement Management template which is provide by Visual Studio 2010 to develop a game. Is there any suggestion about how to save and load the state of a game? Previously I've develop a window phone game and the data is stored inside IsolatedStorage. Is there any similarity for the Window Game?
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForAssembly())
{
using(IsolatedStorageFileStream stream = file.OpenFile("class123.xml",FileMode.Create))
{
XmlWriterSettings setting = new XmlWriterSettings();
setting.Indent = true;
using(XmlWriter writer = XmlWriter.Create(stream,setting))
{
XmlSerializer serializer = new XmlSerializer(typeof(Student));
serializer.Serialize(stream,new Student(){Name = "AhLim"});
}
using (XmlReader reader = XmlReader.Create(stream))
{
XmlSerializer serializer = new XmlSerializer(typeof(Student));
studentA = (Student)serializer.Deserialize(reader);
}
}
}
Here's the code i recently used in Window Game Applicaiton. However, when i reach to Deserialize part, it show InvalidOperationException was unhandled and error on XML document (0,0) . May i know where's the problem?