XNA Easy Storage XBOX 360 High Scores
Posted
by
user1003211
on Game Development
See other posts from Game Development
or by user1003211
Published on 2011-10-24T11:27:15Z
Indexed on
2011/11/27
2:02 UTC
Read the original article
Hit count: 450
To followup from a previous query - I need some help with the implementation of easystorage high scores, which is bringing up some errors on the xbox.
I get the prompt screen, a savedevice is selected and a file are all created! However the file remains empty, (I've tried prepopulating but still get errors).
The full portions of the scoring code can be found here: http://pastebin.com/74v897Yt
The current issue in particular is in LoadHighScores() - "There is an error in XML document (0, 0)." under line data = (HighScoreData)serializer.Deserialize(stream);
I'm not sure whether this line is correct either: HighScoreData data = new HighScoreData();
public static HighScoreData LoadHighScores(string container, string filename) { HighScoreData data = new HighScoreData();
if (Global.SaveDevice.FileExists(container, filename))
{
Global.SaveDevice.Load(container, filename, stream =>
{
File.Open(Global.fileName_options, FileMode.OpenOrCreate,
FileAccess.Read);
try
{
// Read the data from the file
XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
data = (HighScoreData)serializer.Deserialize(stream);
}
finally
{
// Close the file
stream.Close();
// stream.Dispose();
}
});
}
return (data);
}
I call: PromptMe(); when the Start button is pressed at the beginning.
I call: if (Global.SaveDevice.IsReady){entries = LoadHighScores(HighScoresContainer, HighScoresFilename);} during the menu screen to try and display the highscore screen.
I call: SaveHighScore(); when game ends.
I've tried altering the struct code to a class but still no luck. Any help greatly appreciated.
© Game Development or respective owner