Help Load & RW Xml

Put the name and score in a string, use a sprite batch and sprite font to draw that on the screen.

If you have a list of scores, iterate through them putting them in a string, and each time, again use the same method to draw the text.

1 Like

Hang on, ill write you some code…

thank you very much for your help :smiley:
it’s nice

1 Like

OK, I can see your problem, you are not writing and reading the serialized data correctly…

So, I have created an array ot TestClass and called it highScores, I serialize that, clear it out, then load it back in again, just to test.


I can then render this data to ths screen like this in the draw call…

and it looks like this:

No worries,it’s nice to be able to help out,I remember starting out with XNA back in the day, people were so helpfull, it’s nice to be able to pay it back.

Hope this helps.

1 Like

FYI the XML should look like this

Right, I am off to bed, night.

1 Like

Thank you very much fortunately that there are people like you :smiley:

I understood my mistake
I’ve been stuck with this problem for a long time

I am grateful for your help

1 Like

everything works :smiley:
I added a function that sorts in increasing number and I limited my best scores to 5

I manage to write and read without problem

thanks again :smiley:

I have a question

how to display the high score at each start?
I know very well that all the scores are there in the xml file

but each time it starts again from 0
after restarting the application

I tried to put a loop
but I don’t know how to do it :frowning:

I know it’s basic stuff for you May for me it’s brand new I’m learning on my own

thanks in advance

Sorry, but I don’t understand what you are asking…

I know it’s not very clear and my English is not good
I want to display the 5 best scores of player

i succeeded

but when starting the game the scores are not displayed

in my example I have two windows

screen game
and sreen Menu

if there is a collision -> show game over

and display the menu

score: XX

  1. XXX
  2. XXX
  3. XXX

the problem is that the best score is not displayed
it simply shows me the score

when the application is open it works
like the example I sent in the photo

and when I close the best score is not displayed it should be displayed in the Menu screen even before starting a new game

thanks in advance

that’s the idea

thanks again :slight_smile:

if collision —>show screen Menu

I know it’s not clear I have the impression that the information is there but I can’t process it :frowning: :frowning:

everything is there but I’m missing something

for example if I have a score of 10 and I have a collision it will save 10 in xml then it will display 10 as highscore even if I did 20 the old part

First of all, your English is fine, I don’t know what your native language is, but I will bet 100% your English is WAY better than my knowledge of your native language :slight_smile:

You could be making a number of mistakes here,

Before going to the game over screen, you are not storing the new score in the list of scores, so the new score is not added to the list and so does not get shown.

Ideally, you should load the list from xml when the game starts, use and update this list in your screens untill the user closes the game, at which point you then save the list back to the xml file.

I think you have got the serialization and rendering OK, you need to understand how you have implemented your game state/screens.

1 Like


thank you very much i understand my mistake
i think it’s like you said writing score in xml
I will redo the Menu properly and I will try
what do you think of the method?
enum GameState

thanks in advance

The method?

Hello :smiley:
it is from this method
Switch scenes in monogame? to create the menu
I tested it works great :slight_smile:

now i put my code in order

the high score works :smiley:

in the event of a collision it returns me to the menu with the best score

on the other hand if I turn off the app
it no longer displays the old score

i have to find the way how to display the old score

do I have to load the score for example in my playGame method?

can you help me thanks in advance

I did this in UpdateGameplay

in loadContent
i use
_scoreManager = ScoreManager.Load(); // load function with read streamer

//add new score
_scoreManager.Add(new Score()
PlayerName = “PlayerName”,
Value = score,

               //save function score with streamwriter ...