score and highscore

Get help using Construct 2

Post » Sat Nov 09, 2013 12:15 pm

how is the best way to set up the score system? So far i have a variable localscore which resets after level restart and only shows the score gained during the last play. Then i have globalscore which im not sure how to setup. Logicaly the globalscore should be only rewrited if the player has gained more score but i dont know how to set it up

thanx in advance!
B
8
S
4
G
1
Posts: 191
Reputation: 1,873

Post » Sat Nov 09, 2013 5:48 pm

Just do like this.

Add a global variable called "Top score"

Then compare that against local score when the game ends.

if "Top score" < "local score" Set "Top score" = "local score"
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Sat Nov 09, 2013 6:13 pm

nimos thanks, i also need to check the highscore after restarting. I have to save the highscore to webstorage i suppose?
B
8
S
4
G
1
Posts: 191
Reputation: 1,873

Post » Sat Nov 09, 2013 6:40 pm

I haven't actually used webstorage that much, but as I remember there is something about if you clear the cache you might loose it, but you can check that in the manual, as im not sure :D

But yes you could do that.

Just add this to the event where you want to save the score.

To save:
Webstorage -> set local key "Highscore" to Highscore

To load:
System -> on start of layout -> set Highscore = Webstorage.localvalue("Highscore")
nimos1002013-11-09 18:44:33
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Sat Nov 09, 2013 7:08 pm

You can also give it a look at this tutorial
B
8
S
3
G
1
Posts: 135
Reputation: 2,209

Post » Sat Nov 09, 2013 8:49 pm

Nimos thanks but it seems that im making some mistake. Can you please give me more detailed instructions on how to do this:

when i first finish a level i need to set this as a score and highscore aswell - i need to save the highscore. When the level is replayed, i need to load the highscore and compare it with current score. The higher will be set as text.

thank you!
B
8
S
4
G
1
Posts: 191
Reputation: 1,873

Post » Sat Nov 09, 2013 9:56 pm

I use web storage that's the best way I've found.
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
38
S
18
G
4
Posts: 365
Reputation: 6,239

Post » Sat Nov 09, 2013 9:59 pm

B
101
S
32
G
11
Posts: 1,546
Reputation: 21,727

Post » Sat Nov 09, 2013 10:31 pm

wow thanks ArcadEd :)
B
8
S
4
G
1
Posts: 191
Reputation: 1,873

Post » Sat Nov 09, 2013 10:32 pm

[QUOTE=marcel1980] Nimos thanks but it seems that im making some mistake. Can you please give me more detailed instructions on how to do this:

when i first finish a level i need to set this as a score and highscore aswell - i need to save the highscore. When the level is replayed, i need to load the highscore and compare it with current score. The higher will be set as text.

thank you![/QUOTE]

Here is how you can do it, I just made it with some buttons to simulate how it should work, you just have to put them into the correct places ofc.

However I would strongly suggest that you use functions to do it, as it would be a lot better. This example is just to show how to do it and to keep it as simple as possible, but if you know how to use functions I would strongly recommend doing that.

Highscore test
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Next

Return to How do I....?

Who is online

Users browsing this forum: facecrime, zenox98 and 7 guests