How to make the value of a variable or global variable persist after exiting the game. There are coins in my game, and it is important for me that they are saved.
The save events are write/read from storage.
I also thought about it, but it is too difficult, since each coin will need a separate event, it is too long and difficult. In short, it doesn’t suit me.
do you have a different global variable for each coin?
i assume you only have one, and that’s the one you save.
it is not complicated, nor do you need alot of effort/events.
if you have many different variables to save, then i recommend to use a global variable structure.
have a global variable (save) and have all variables, you want to save as a child of it.
like, globalVariable save.coins / save.items /save.level ect.
then you save the entire structure as a JSON String and load it when you start the game.
how to do so: