How to use local storage properly in turn-based game?

0 favourites
  • 2 posts
From the Asset Store
A well commented RPG game template to learn from or use as a base for your own game!
  • I'm making turn based game. There is a game field where player move objects every turn.

    Every turn I save whole game field as json in local storage.

    How to use local storage properly for saving game?

    I've noticed that loading field with chain "on exist"->"load array from JSON" works with bugs. So I've added signal after "load from JSON". And before starting old game I've added waiting for that signal.

    Now it works without any bugs.

    Should I use same "signal"-"wait signal" mechanism for saving game? So player won't be able to leave game before game field is recorded in local storage? If yes then what is the best way to do it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Most problems with Local Storage happen when people are trying to access data before it's loaded. Or writing and reading data simultaneously in one tick. If you avoid making these mistake, then LS should work just fine.

    Unless your JSON data is very large, saving/loading should take a fraction of a second. You can add a wait of 0.5-1 seconds, but to be safe use "LocalStorage On exist" or "LocalStorage On set" events. For example, if you need to save to LS and switch to another layout, move "Go to layout" action into the "LocalStorage On item set" event.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)