How can I make a more efficient way of saving?

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Global plugin that allow for relatively easy and efficient implementation of an in-game inventory system
  • I have made a mobile version of my Planet Clicker, to run in the form of an app. I have made a system that saves the game every 15 seconds, saves the JSON as a Dictionary Value, then saves the Dictionary as JSON to Local Storage. However, after a little bit, the save takes around 10 seconds and freezes the UI (Music isn't affected), and on my iPhone 13 Mini that I sideloaded the IPA to, it even crashes. Is there a more efficient way to save the game for mobile?

    I needed to change it to 15 seconds, it was originally 2, but that was way too much for it to bear. I want it to be like a normal app that progress is typically saved instantly, or more so just stored on the device plain.

    I also need to use the `Save Game to Slot "xxx"` because my game is full of persistent objects.

  • If you want a more efficient save, you'll need to consider and define only what you absolutely need to save, and do so manually. If it's still taking too long, you might consider changing the format and contents of the data you're saving to something smaller or more simple. Depends on your game really.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How big is the JSON file? Try saving it to your desktop using the "Browser Download string" action. Then, analyze it with an online tool to see which objects are taking up so much space.

    My guess? The dictionary.

    You’re writing saveJSON into the dictionary. Then, 15 seconds later, you create a new save, which stores the entire dictionary (already containing the previous save) into saveJSON again. After that, you write saveJSON back into the dictionary.

    It’s like Russian dolls — your dictionary keeps nesting copies of all previous saves.

    The solution is to clear the dictionary before running "System save".

  • Thanks for the response! I didn't think about it, but I guess that would be the problem. However, I instead made an array as well as a backed up all of my variables to the dictionary, and saved them both to local storage as JSON, and I feel like it works better this way. There was always a very short, but somewhat noticeable stutter when system saving across every game I've made, so I set it to 15 seconds, but now I can have it save every 1 second without any noticeable problems.

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