Highscore either stays at 0 or says NaN

Get help using Construct 2

Post » Sun Apr 28, 2013 8:15 pm

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!



Any idea of where Ive done wrong? If the screenshot is not enough, I can provide .capx file too..
Thanks in advance.
B
4
Posts: 15
Reputation: 580

Post » Sun Apr 28, 2013 8:26 pm

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 workAphrodite2013-04-28 20:33:19
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
43
S
18
G
18
Posts: 2,106
Reputation: 16,436

Post » Sun Apr 28, 2013 8:33 pm

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


B
4
Posts: 15
Reputation: 580

Post » Sun Apr 28, 2013 8:37 pm

I See, The Webstorage keys are strings!

WebStorage.LocalValue("highscore"), don't forget the " "
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
43
S
18
G
18
Posts: 2,106
Reputation: 16,436

Post » Sun Apr 28, 2013 8:41 pm

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

I can give ya the .capx if you want to try it yourself?
B
4
Posts: 15
Reputation: 580

Post » Sun Apr 28, 2013 8:42 pm

If you don't mind, yes, I could give it a try ^^Aphrodite2013-04-28 20:44:57
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
43
S
18
G
18
Posts: 2,106
Reputation: 16,436

Post » Sun Apr 28, 2013 8:48 pm

Ive PM'd you with the .capx file. Please oh please find the problem :/
B
4
Posts: 15
Reputation: 580

Post » Sun Apr 28, 2013 9:10 pm

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")
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
43
S
18
G
18
Posts: 2,106
Reputation: 16,436

Post » Sun Apr 28, 2013 9:16 pm

[QUOTE=Aphrodite] 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")[/QUOTE]

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

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

B
4
Posts: 15
Reputation: 580

Post » Sun Apr 28, 2013 9:28 pm

[QUOTE=DV7] [QUOTE=Aphrodite] 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")[/QUOTE]

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

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

[/QUOTE]

Yes, also, you could do that during the game over
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
43
S
18
G
18
Posts: 2,106
Reputation: 16,436

Next

Return to How do I....?

Who is online

Users browsing this forum: SoldjahBoy, Yahoo [Bot] and 1 guest