Localstorage issue

Discussion and feedback on Construct 2

Post » Sun Dec 27, 2015 11:47 am

Hi all,

I'm getting towards a point where I can publish my game to iOS and Android, but I'm having an issue with localstorage which is making me scratch my head a bit.

The game functions correctly, and I'm using localstorage to save the hi score and the audio on/off toggle, and now I'm adding in achievements to add a bit of longevity. To drive a few of the achievements, I have to store the total number of enemies killed - so each time an enemy is destroyed, I add 1 to the global variable TotalEnemiesDestroyed. So far, so good. On player destroyed, I'm then setting the localstorage item totalEnemiesDestroyed to the value of the variable TotalEnemiesDestroyed.

This is working whilst in the game, but if you exit and come back in, the value is wrong, like it's not saving properly or not loading properly on my Start layout.

So... My question is, are there any limitations with localstorage that I need to know about? Should I try loading everything in my splash screen instead and not progress until it's all loaded? Is there a better way of storing all the data I need to save rather than having separate localstorage items?

Sorry if I've not explained this very well! Any help or comments would be very much appreciated. I want to finish Swarm so that I can start on some new games :) thank you in advance!
B
7
Posts: 12
Reputation: 329

Post » Sun Dec 27, 2015 12:40 pm

I don't think there are any limitations at least in how you want it to work for your game. Since the value is wrong when you return to the game, it must mean that you are saving it wrongly. You will need to look at your events again, or post a screenshot or capx here for others to take a look at.
B
42
S
20
G
31
Posts: 685
Reputation: 20,221

Post » Sun Dec 27, 2015 5:22 pm

As I know, there are no limitations. Make sure that you set your global variable TotalEnemiesDestroyed to localstorage value totalEnemiesDestroyed before you play, so the value goes from where you have left, and not from 0.
B
32
S
7
G
4
Posts: 397
Reputation: 4,589


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests