Please How do I ???

0 favourites
  • 4 posts
  • Hey Folks!!!

    I've got a slight problem.

    I've managed to make my score and high score work properly using local storage, thanks to some of you guys out there,

    but I've got Another problem.

    when I refresh my ipad/game my high score is back to 0.

    Any ideas on how to fix that?

    please keep it simple I am a very beginner on this.


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You need to load your score value on start of the game's execution.

    See this tutorial, I explained how to do it for several systems, including the score system.

  • Wow!

    I don't really get it, that's way to complicated for me!

    Is there another way to understand it?

    Everything is working as it should on the computer, the high score saves itself even when i close everything down and restart the game!

    It work 100% as i want it to do.

    on the computer i can close down everything, open the game after an hour and the high score is where it should be.

    the problem is when I open the game on a mobile device, eveything is working perfectly, my high score is working as it should, it upgrades as i'm beating the high score, and it saves itself as i keep on playing, as long as I'm not closing down the game.

    when i close down the game completely on a moblie device and re enter an hour later the game restarts from 0, and my high score is back to 0.

    Any easy way to manage this?

  • I would believe from your description that you are not creating a local storage key on your mobile game.

    You did at some point on your test computer, so the key exists, and you apparently have code that DOES save the value into the key.

    On the mobile though, you possibly only try to load a value from a key that does not exist.

    As I explained in the tutorial, you need, the first time you execute your game on the device to create the key and populate it with a default value.

    So in a "On start of layout" in the first layout of your game, have an action that checks if your local storage key exists (Check item YOURKEY exists).

    If it does exist, (event "On item YOURKEY exists") then you set the value of your global variable score to the value of the key YOURKEY in the local storage.

    If it does not exist (event "On item YOURKEY missing") then you start by creating the key action "Set item" YOURKEY to a value of 0 and set the value of your global score variable to 0 as well.

    If the rest of your code is correct (and that you are always using the correct key YOURKEY name), all should work as intended.

    Otherwise, do post your capx, that will be the easier way for other people to possibly see where you are going wrong.

    If you feel it is too complicated, take your time.

    Read several times, over several days the various explanations (and tutorial) and it should become clearer after a while.

    Game executed

    First time ever ? (no key exists) => Create a key

    Not the first time ? (a key exists) => Set the value of the variable to the value stored in the key

    Ending the game ? => Save score in the key before the user has exited.

    At worst, delay the exit so the score IS saved.

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