Problem with highscores

Get help using Construct 2

Post » Mon Feb 10, 2014 1:55 am



Im trying to add a highscore to my game, but the values dont save

i tried those tutorials:
https://www.youtube.com/watch?v=06-LgQxceGg

https://www.scirra.com/tutorials/266/webstorage-how-to-save-ingame-information
B
13
S
3
G
1
Posts: 51
Reputation: 971

Post » Mon Feb 10, 2014 2:23 am

Hi.

A few things I can see wrong here.

You need to save the data to webstorage AsJSON so simply add the following excluding the ""'s after "pontos" in the very last line of your code so it reads set localkey "Highscore" to pontos.AsJSON

Which solves the other problem that you set pontos as a global but in this line of code it's enclosed in "" which the computer then reads as a string

So if pontos had a value of 100 then typing pontos will record the value 100 but typing "pontos" will record the value pontos.
If the programme is expecting a number and it gets a string you have problems.

Then delete the 2nd instance of on start of layout/Local key highscore exists it's not neccesary.
Then you have problems with Highscore you'll notice "" are back on two but not the first usage.
Have you called an object the same name as a Global (pontos)?

TBH it's a little messy if you could upload a capX it will be easier all round.


In the meantime the suffix .AsJSON is your friend have a read up on it and watch out for Globals in ""'s.
There are 10 types of people in the World, those that understand binary and those who don't.
B
7
S
2
Posts: 93
Reputation: 797

Post » Mon Feb 10, 2014 2:39 am

thx

i did everything, and didnt worked
i changed "pontos" to score and i got this when i tried to change the asJSON thing



ps: the object "pontos" its a hitbox
when the player colide with pontos, 1 is added to pontos(now score)PlayerEmers2014-02-10 02:40:38
B
13
S
3
G
1
Posts: 51
Reputation: 971

Post » Mon Feb 10, 2014 2:42 am

hey, i didnt used .AsJSON, and IT WORKED
dunno why worked without AsJSON, but FINALLY

thx mate for everything
B
13
S
3
G
1
Posts: 51
Reputation: 971

Post » Mon Feb 10, 2014 4:16 am

hm... worked fine when i tested from construct 2
but on dropbox isnt working

https://dl.dropboxusercontent.com/u/36301251/flappydoge/index.html

is this a problem? or its just dropbox?
B
13
S
3
G
1
Posts: 51
Reputation: 971

Post » Mon Feb 10, 2014 2:09 pm

trying to create a APK to test on my phone to see this highscore thing
someone know if its a dropbox problem?
B
13
S
3
G
1
Posts: 51
Reputation: 971

Post » Mon Feb 10, 2014 2:28 pm

So you have an object named pontos, and a variable named pontos (which is now called score). I don't know hwat AsJSON is but I've never used it although I've never tested my high scores beyond the built in emulator

Are your objects on the same layout? I was playing with the vertical jump template and mine wasn't working. Turned out the text fields I wanted to update were on a different layout so I had to move my WebStorage actions and events over to that layout.

Maybe set up a text field on your main layout and see if it updates? Have one with the current score and one with the high score. Also small thing but should your highscore variable start at 0?
B
5
S
1
Posts: 44
Reputation: 465

Post » Mon Feb 10, 2014 2:53 pm

[QUOTE=Magnatolia] So you have an object named pontos, and a variable named pontos (which is now called score). I don't know hwat AsJSON is but I've never used it although I've never tested my high scores beyond the built in emulator

Are your objects on the same layout? I was playing with the vertical jump template and mine wasn't working. Turned out the text fields I wanted to update were on a different layout so I had to move my WebStorage actions and events over to that layout.

Maybe set up a text field on your main layout and see if it updates? Have one with the current score and one with the high score. Also small thing but should your highscore variable start at 0?[/QUOTE]

yeah they are in the same layout, its working fine on OFFLINE PREVIEW (construct 2) but on dropbox isnt working
thats the problem
i'll test the android version now
B
13
S
3
G
1
Posts: 51
Reputation: 971

Post » Mon Feb 10, 2014 3:16 pm

is not working on android too
only works when i test offline with construct 2
pls help
B
13
S
3
G
1
Posts: 51
Reputation: 971

Post » Mon Feb 10, 2014 6:07 pm

If you could upload a CapX I'll have a look later on for you.
There are 10 types of people in the World, those that understand binary and those who don't.
B
7
S
2
Posts: 93
Reputation: 797

Next

Return to How do I....?

Who is online

Users browsing this forum: Artcadev, brunopalermo and 18 guests