How do I test if I have local storage working correctly

0 favourites
  • 8 posts
From the Asset Store
"Easy Local Notifications" enhances games with customizable local notifications.
  • Hi Everyone.

    After 2 months I'm not on the final bit of my game, local storage.

    I've followed instructions to create a local storage for the game but when I've converted the game to apk for android it didn't save it.

    I then tried a different tutorial on local storage, converted and still didn't work on the android phone.

    Before I keep going trying different ways, is there a way for me to see if I've done it correct using the preview on my PC?

    Once I know I've done it right then I can at least work out there's a problem between Cordova and intel XDK.

    Thanks for any help.

  • You should be able to check if it's working correctly with preview.

  • Hi,

    Thanks for the reply, I thought local storage would allow the person to play a level and get a star.

    Then when they close the app/game down and come back to it later the local storage remembers that the player got a star.

    I thought web storage is for browers, eg: If I'm previewing on my PC.

    How would local storage work on preview? eg:

    When I click preview the game loads in and everything is reset, no star.

    I play the game and win the star.

    But in order to close the game down I have to press x to close browser.

    But to load that game back I need to click preview and it clears everything when it loads.

    Are you saying that it shouldn't be clearing each time?

    Sorry,

    Thanks

  • Web storage is redundant now and just the name for the old version of local storage. If it has cleared when it loads I think it isn't working correctly, it should save data. I might have to make a capx to check but as I recall the browser data is still stored on preview. To clarify, local storage is game data, usually 'keys' stored locally in browser data.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah,

    Thanks, so as an APK on android does the local storage still store as browser data if the game doesn't require the browser?

    I think I know what the problem is then, I'm using a sprite with global (because all my other normal globals have to reset each level) the sprite global remains unaffected.

    But I don't think the local storage likes the sprite global?!

    I have about 20 instances on that sprite global, eg: Level 2 button visible, Level 3 button visible and so on.

    Would I need to make a local storage (key) for each of the 20 instances or should I have not used the sprite?... gulp.

    I'm opening up another construct 2 and will try testing different ways.

    Thanks so much for your help.

    P.s run layout is the same a preview?

  • Yes if you use local storage it should just create the key data on the mobile device in the same way. Once you have it working with the preview (run layout) on the PC you will likely see it working on the mobile app unless something went wrong along the way with the third party plugins, I guess that would be a separate issue. Ensure it is working on preview browser first, if your data is refreshing every time then there's a problem with your events.

    In terms of what you're describing for the save data. Couldn't you just save one variable that unlocks stages of your game based on what the variable is? i.e. if the variable is 3 then levels 1- 3 are unlocked.

  • Thanks,

    I done some tests and because the sprite is the global I can't select it like I would a normal global.

    So I took your idea about saving variables but I tried 'load game' on start of layout and 'save game' when the sprite for button 2, 3, 4 is visible etc.

    So far that's working and saving everything including the stars, I'm going convert to apk now and will report back in case this helps someone else in the future.

    Thank you for all your help.

  • The save / load works on the phone, I'm sure I gone about it all the wrong way, but I've got the result in the end.

    Thanks for your help.

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