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.
Hang on, ill write you some code…
thank you very much for your help
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.
Thank you very much fortunately that there are people like you
I understood my mistake
I’ve been stuck with this problem for a long time
I am grateful for your help
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
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
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
but when starting the game the scores are not displayed
in my example I have two windows
and sreen Menu
if there is a collision -> show game over
and display the menu
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
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
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
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.
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?
thanks in advance
it is from this method
Switch scenes in monogame? to create the menu
I tested it works great
now i put my code in order
the high score works
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
_scoreManager = ScoreManager.Load(); // load function with read streamer
//add new score
PlayerName = “PlayerName”,
Value = score,
//save function score with streamwriter ... ScoreManager.Save(_scoreManager);