Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Swirly cogs |
Hi all. I’m a new beginner to both coding and game engines so please bear with me.
I completed the “dodge the creeps” tutorial and have been working to expand it by learning new things. From browsing around i see lots of information about saving the high score and believe i have an understanding of the code but am stumped by where to add it in the code/scenes. does it need to be in a global script by itself or can it be placed in any scene? also how do i access it to say update a label on my menu screen with the highest score?
Thanks in advance
What do you mean by you “have understanding of the code”? I don’t think you’d want to put it in any scene (Enemy for example). There’s not really a need for a global script, since this game only has one running scene anyway.
There are two parts to the process:
- At application start, read the highscore from the score file (in
_ready()
for example) - At game end, if score > highscore set highscore and save it to score file (in
game_over()
for example) - Set the label text using the highscore variable
If you can update your post with more specific question(s) I’ll be happy to help you with them.
kidscancode | 2018-09-10 20:32
Thanks for replying. Your videos are one of the main reasons i’m here as i find them the best to be able to watch. Fan moment over :
By understanding i mean that i understand where you have to make the file and check if it exists already then read from it and write to it (maybe i don’t understand it as in depth as i should).
I believe just the processes you have mentioned above have answered what i was after. For the first two points would this all be inside the ready and game over script in the main scene?
For the label text do i just retrieve the highscore from the save file with code scripted in the label itself?
Swirly cogs | 2018-09-10 20:58