Highscore either stays at 0 or says NaN

  • Howdy!

    So, Im pretty much done with my first (android)game ever, the only thing missing is highscore.

    I started on that part back on friday, but couldnt make it work, so I left it for saturday and after another failed attempt, I told myself that I'd fix it today but Im still stuck after some hours of messing around trying to fix it :(

    The problem is that the highscore either stays at 0 or says NaN, and I cant figure out why. Ive been searching for tutorials, but pretty much none of them are based on how to store highscore locally on the device. I found a video (https://www.scirra.com/tutorials/448/arcade-style-high-score) though and Ive done the steps over and over but it simply does not work and its driving me nuts!

    <img src="http://i40.tinypic.com/29y4kk0.jpg" border="0" />

    Any idea of where Ive done wrong? If the screenshot is not enough, I can provide .capx file too..

    Thanks in advance.

  • Did you check that WebStorage Works on the tested device? (and did it works in the computer?)

    EDIT: I ask that because, as far as I see, It should work

  • Thanks for replying! Does not work on either computer or device (Samsung Galaxy S3) after export with CocoonJS.

  • I See, The Webstorage keys are strings!

    WebStorage.LocalValue("highscore"), don't forget the " "

  • I've added the " ", but the highscore still remains at 0 :(

    I can give ya the .capx if you want to try it yourself?

  • If you don't mind, yes, I could give it a try ^^

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ive PM'd you with the .capx file. Please oh please find the problem :/

  • The problem is your "set local key"

    you just have to enter the name of the key, here "highscore" (with the " " ), not the WebStorage.LocalValue("highscore")

  • The problem is your "set local key"

    you just have to enter the name of the key, here "highscore" (with the " " ), not the WebStorage.LocalValue("highscore")

    Uh, sorry if I seem stupid now, but I dont get what you mean :P

    Do you mean event 13? WebStorage.LocalValue("highscore") ?

  • > The problem is your "set local key"

    > you just have to enter the name of the key, here "highscore" (with the " " ), not the WebStorage.LocalValue("highscore")

    Uh, sorry if I seem stupid now, but I dont get what you mean :P

    Do you mean event 13? WebStorage.LocalValue("highscore") ?

    Yes, also, you could do that during the game over

  • But... didnt I already do it in the provided .capx?

    <img src="http://i42.tinypic.com/331fthl.png" border="0" />

    edit: Or have I completely missunderstood you?

  • you did

    Set the local key WebStorage.LocalValue("highscore") to score

    you should do:

    Set the local key "highscore" to score

  • you did

    Set the local key WebStorage.LocalValue("highscore") to score

    you should do:

    Set the local key "highscore" to score

    Like this?

    <img src="http://i44.tinypic.com/nm0s92.png" border="0" />

    If that is what you meant, that doesnt work either. highscore stays at 0 :(

    Or I might have missunderstood you again :P

    If so, could you send me .capx with how you have done via PM?

  • Done, I hope this time, it works, for me, it worked, I also set the webstorage key Before changing layout, the event sheet process from up to down

  • It works! Thank you so much for taking your time to help me out!

    Cheers :)

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