How do I make highscores Construct2

Get help using Construct 2

Post » Wed Mar 26, 2014 5:55 am

Message: Kaelus is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
Hi, I was following the tutorial on the highscores for construct2() and i must admit that it was very well done. However i'am having a little problem. I'am making an infinite runner game,it has a score system but the highscore is not working. It's always at zero. The reason I'am thinking it happens is because if the player falls then there is a reset global variables to default event that occurs and might affect the highscore variable(not sure tho). Do you know how to fix it?
I won't be able to send you a capx file because the game is set to be released soon and the art can't be seen yet. However it mostly uses the event of the infinte run template on construct 2 slightly modified so u could use that as a base. I would really appreciate if you respond ASAP as i'm running out of time. Thanks
PS: I asked for help a while ago and didn't choose the notify button. I received many replies very fast and as i found the solution myself didn't even check. I feel terribly sorry and am very happy about this community T-T
B
8
S
1
Posts: 11
Reputation: 478

Post » Wed Mar 26, 2014 6:25 am

@Kaelus You do not need to place a full capx with your whole game and art, you can just reproduce the lines of code in an example (especially if you used a template), just put placeholders like boxes. If not, then, can you at least place an image of the section where you are evaluating the high score? I followed the tutorial and it works fine for a runner. It is really hard to review/help with something without seeing the code (too many assumptions have to be made...).
B
8
S
3
G
1
Posts: 135
Reputation: 2,209

Post » Wed Mar 26, 2014 2:42 pm

Hi, here is a demo of the game with construct's art
You do not have the required permissions to view the files attached to this post.
B
8
S
1
Posts: 11
Reputation: 478

Post » Wed Mar 26, 2014 11:47 pm

@Kaelus there are some issues in the code.

You are not using the webstorage correctly. You also placed a Set Highscore to Highscore, therefore, and you defined highscore=0 ... so you will always have highscore as 0.
Another thing is that the order of execution does matter. When you die, you reset the global immediately... instead, you should have the webstorage (as step 3 below) and then reset the variables and layout. If not, you are just resetting and saving the highscore as 0.

1. Try this, use " " for all highscore value
2. On the start layout -> Webstorage -> Local key "highscore" exists | System -> Set highscore to WebStoreage.localValue("highscore")
3. On comparing the distance, webstorage-> set local key "highscore" to totaldistance

That worked on the mini test I did.
B
8
S
3
G
1
Posts: 135
Reputation: 2,209

Post » Thu Mar 27, 2014 3:24 am

Thaaank you so much,it worked!! Not only did I learn that the order of events matters but that so does the quotation mark. You're the best!
B
8
S
1
Posts: 11
Reputation: 478


Return to How do I....?

Who is online

Users browsing this forum: AndreasR, Google [Bot], tarek2 and 12 guests