[request] capx example for LocalStorage

0 favourites
From the Asset Store
Unlock platyers earning coins, and save it with Localstorage
  • I am embarrassed. I read, read and reread the lessons dedicated to the LocalStorage or Array/dictionnary and there is nothing to do, it does not work for me. This must be my brain completely allergic to this type of logic.

    I managed to set a coin storage system, with great difficulty and with kindness of AndreasR. Unfortunately I also need to add an highscore system. But just by this idea, my brain is already beginning to burrow deep in my skull.

    Would someone be kind enough to share a capx example that shows how a multiple values storage is set up?

    Please!!!! (crying) Please... My wife left me for my brother, my children do not want to see me, I lost all my money in the last financial crisis, my english is so bad, my club foot hurts me since I can not pay treatment against cancer. Please Help!

  • Okay. That was good. You could throw in, "My dog/cat won't look at me anymore."

    Did you already see these two tutorials I put together?

    For Dictionary ...

    http://javajdk.net/tutorial/construct-2 ... -tutorial/

    and for LocalStorage ...

    http://javajdk.net/tutorial/localstorag ... nstruct-2/

    I have a zipped capx for the LocalStorage one linked on the tutorial. I will add a zipped capx for the Dictionary one in a few minutes.

  • In fact, my problem is that I fail all time I try to put together localstorage, variables and dictionnary/array. Values reset at layout restart.

    All examples I saw until now are talking about a part of how to do a multiple value storage. I really need an example that would shows me how to do it from A to Z.

    Thank you for help and by the way your tutorials are well done.

  • Have a look at my blog http://myconstruct2dev.blogspot.co.uk/ which has several in the github, the best explanation of the code is probably in the asteroids post.

  • I already seen your blog, but it doesn't help me much :/

    I'm still stuck....

    Thank you anyway.

  • Hi norab

    I guess you already have downloaded my Coin example here?

    https://shatter-box.com/downloads/const ... alstorage/

    It's fairly the same if you want to save a dictionary or an array in the LocalStorage. You just need to fill it by setting the value of to global variable to an x,y or/and z coordinate in the array.

    Then save the array via 'AsJSON' in the LocalStorage.

    I have an example for that. It's available in the store.

    https://www.scirra.com/store/royalty-fr ... torage-973

    This example includes code snippets showing you how to save arrays and dictionaries.

    Regards

    Andreas

  • Thank you for your suggestion AndreasR.

    Maybe the best way is to show what I did, and then someone could tell me what am I doing wrong.

    In the example below, I did a mutltiple value saving system with array and webstorage but I have trouble to do it with LocalStorage (my array is stored, i can see in in debug mod, but I dont know how to return it to my text object):

    my test

  • OK, 2 threads and some frustrated posting by you in your other thread on this subject, because no one understands your problem with local storage... However, your problem is nothing to do with the local storage, it's to do with putting a value into a variable from a retrieved save of an array (and putting that into a text object)!!

    Lesson 1 - if you're stuck, provide a capx so people know what you're referring to.

    Lesson 2 - if you're not sure what you're doing and you ask for help, try to understand the help you get, or see Lesson 1.

    So, from your capx - you are not saving the global variables, just the array - which is ok. But you are using the global variables to update your text objects - unless you change something, the text objects and global variables will never be updated when the array json is loaded. Also, you are only updating your text object when a button is clicked, you should put that update into a function and call it when a button is clicked or if your saved data is retrieved (assuming you alter the events to save and retrieve the data you want).

  • Have a look at my blog http://myconstruct2dev.blogspot.co.uk/ which has several in the github, the best explanation of the code is probably in the asteroids post.

    I love your blog. I spent some time playing your asteroids game today. Very nice.

  • I checked your capx file & updated it.

    Capx: https://www.dropbox.com/s/in1izt3gsorv6 ... .capx?dl=0

  • Lesson 1 - if you're stuck, provide a capx so people know what you're referring to.

    +1

    AndreasR

    Thank you very much, you're really nice

  • Try Construct 3

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

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

    > Lesson 1 - if you're stuck, provide a capx so people know what you're referring to.

    >

    >

    +1

    AndreasR

    Thank you very much, you're really nice

    You're welcome

  • I also put up a capx for Local Storage and using a dictionary.

    https://www.dropbox.com/s/61kstfx7pbr3j ... .capx?dl=0

  • hi guys.., im having the same issue as above.., I cant save my high score with local storage.., ive been looking and trying many tutorials but still can geit it done.., I emailed scirra and they ask me to ask in the forum., my game is just a simple game like flappy bird.., after the bird dies, the current score and high score pops out.. i want to save the high score even after i restart the app., this is my first try making game in construct 2.., somebody ? thx

    i cant seem post my capx due to lack of reps.. D:

  • fiepaper - Did you download my capx and look it over?

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