Fixed issue with cookies storage.


Since the game is using local storage to store the high score, some people were getting an issue if they had third party cookies blocked in their browser settings. The issue was I was calling the functions "localStorage.getItem()" and "localStorage.setItem()" which was throwing an error causing the game to break. 

The issue was fixed by wrapping the functions inside a try catch block. In the block I am able to catch the error thrown and keep a default value high scores. I also wrapped the try catch block in an if statement checking for "navigator.cookieEnabled". With this check I can check to see if cookies are enabled before trying to get or set the local storage. This will prevent the function calls from being unnecessarily called to begin with.

Files

turkey-hunt-html.zip Play in browser
Version 2 Dec 02, 2020

Leave a comment

Log in with itch.io to leave a comment.