LocalStorage "On all sets complete" not working?

0 favourites
  • 8 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I'm trying to use LocalStorage to keep track of levels that players are completing in my game, but I am having a hard time getting the game to actually save the Array.AsJSON to LocalStorage.

    I tried using "On all sets complete" to see how long it was taking to save the file before the player could move on to the next level, but I can sit for minutes and it still isn't calling the events.

    Is there a workaround to this? Am I doing something wrong?


  • Your link doesn't work. If you are setting one item, try using "On item set" event.

  • Sorry, I was making a bunch of changes to try to improve performance of the file on Mobile.

    I tried what you said for this version (I'll leave it up until you respond)...


  • You are setting item "Muted" on every tick and probably other items too ("LevelReached", "LevelArray" etc.) Reading from and writing to local storage on every tick is a serious mistake, don't do this!

    Also, you have "On item set" events nested under other events, which may cause them to never trigger. They need to be top-level events.

    Take a look at this demo, showing an efficient way to use local storage, you can open it in trial version of C3.

  • Alright. I got a bit more liberal with my use of the Trigger Once While True command, and un-nested the "On Item Set" like you recommended.

    My goodness, thank you so much! It works!

    You probably have some idea how much I was banging my head against surfaces trying to get this working. I am beyond appreciative. I also am deathly afraid to touch anything now in case I break it worse.

    If I could give you something more than this thumbs up, I would.

  • I don't like "Trigger once", it can cause many problems when used incorrectly.

    Make sure to only save items to local storage when needed - i.e. after finishing a level, when settings has changed etc.

  • Really? What kinds of problems? I use it fairly frequently when my events cause issues by happening over-often. Besides dictionaries for intermediary saving, what are other things you do to avoid using Trigger Once?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The most common mistake is using it with multiple instances. For example "if Enemy health=0, Trigger once : Enemy set animation DEAD". This looks good, but it will not work with multiple enemies. Also, people often put this condition inside triggered events, loops, which can produce some weird results.

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