Hey sorry for the late response, I haven't had a chance to work on this for a while.
On some testing attempts I did quit back to the Start Menu after setting a high score. The Start Menu was my first layout and also where I made the read from Local Storage.
This could definitely have triggered the problem you suggested of saving and then immediately trying to load. I would also be making unnecessary checks from Local Storage every time the player goes back to Start Menu.
On other attempts though I just closed from the main game after the Game Over layer was visible and the "HighScore" item set (if Player.Score > HighScore). That shouldn't cause the overlapping save/load issue, but maybe I exited too soon and the new "HighScore" item was never set successfully.
I created a new layout ("Loader Layout"), set it to First Layout, and then checked the use loader layout box. I moved the original Local Storage load block (check item exists, set global variable HighScore to LocalStorage.ItemValue, item "HighScore" missing set item "HighScore" to 0) to the Loader Layout event sheet.
This would make loads from Local Storage only happen once when the game starts and not get triggered by every quit to Start Menu. It should also prevent potentially attempting to load when it's already trying to save.
The new load up worked on the computer (I even cleared Local Storage to start from scratch), but it still didn't retain the high score on mobile. I began to question whether the saves to Local Storage were happening at all with the phone so I further adjusted the game over events.
Now, when the game over conditions are met and the player sets a new high score, I don't even show the game over layer until On item "HighScore" set is complete. The layer actually does become visible indicating a successful save.
I also edited the Loader event sheet so that the player cannot advance to the Start Menu until either:
- On item "HighScore" exists is complete and the HighScore global var is set to LocalStorage.ItemValue
- if item "HighScore" is missing and set to 0, On item "HighScore" set complete.
Even with these extra measures to prevent interrupting saving and loading, the high score is still lost from Local Storage on mobile remote preview when closing and reopening (still with same link).
I thought these last couple of tweaks would have cracked it for sure, but I'm still managing to screw this up somehow. Maybe I did the Loader layout wrong, but that seemed pretty straightforward and the new set up still works perfectly on the computer.
Anyways thanks again for all the help, I really appreciate it. If you have any other ideas or need any more info please let me know.