So I thought that localStorage stored all of your data unless you clear your browser cache. I’m doing a localStorage.setItem("playerData", playerData) where playerData points to my playerData object that stores my data. If I setItem in the Tutorial level, I’m able to getItem in the next level, no problem. But then if I go to my main menu and I click my Load Save button which on pointerdown has an event that this.scene.start(playerData.level) where playerData.level is a string that changes when you reach a new level to the appropriate super() keyword value is updated in the playerData, my scene will not load. I did a console.log(playerData.level) on my menu scene and it sees my playerData.level string as empty. So it has no scene to load.
Figured it out. I just had to change some things around for this.scene.start()
When I passed localStorage.getItem("playerLevel") to this.scene.start() everything worked great.
I created another localStorage.setItem("playerLevel", playerData.level) so I think I need to store individual properties from my playerData file with separate keys.
are you sure you are cleaning up your click events properly? It is entirely possible that you have multiple listeners. Add a console.log on your pointer down event and check it out.
Always use JSON.stringify and JSON.parse when using localStorage.
E.g: localStorage.setItem('p', JSON.stringify(p) p = JSON.parse(localStorage.getItem('p'))
So I shouldn’t use a javascript object for data storage, it has to be JSON? That’s fine and I can modify what I have but the javascript object seems to work great.
Hmm, okay. Its so interesting. It’s working exactly how I would expect without having to stringify and parse. But I’ll look up stringifying and parsing javascript objects to make it correct.