0

sorry in advance if this seems trivial. Read a few tutorials/notes and still cannot get my head around this...

I am currently making a puzzle game in which the player controls a character. Each time the character moves "1 map tile" in any 4 way direction (N,S,E,W) an int will +1. The number of this integer is currently displayed on the game screen along with some small text, informing the player of their current "moves".

spriteBatch.DrawString(debugfont, "Moves Taken: " + MoveCounter, Vector2.Zero, Color.White);

What I want to do is take the information that's being stored/displayed above and place it into an external file (.txt) which can then be viewed at a later stage when the user chooses the "HighScores" option from the Main Menu.

4

1 回答 1

0

File.AppendText and TextWriter.Write is possible approach:

using(var output = new File.AppendText("highscore.txt"))
{
    output.Write("Moves Taken: {0}", MoveCounter);
}
于 2013-05-03T04:57:01.260 回答