Highscore is not working

Get help using Construct 2

Post » Wed Feb 19, 2014 9:16 am

This is what I did:
Create two text objects(t1 and t2(t2 in the game over))
Global,highscore
Global,Score
Every 0.1 seconds
-Add +1 to Global variable Score
I have a player who flies and if he collide with the floor,
-Go to Game over layout
Every tick
-Set t1 to Score


In the gameover layout, If Global,Score > highscore
highscore set to Score.
t2 set to highscore

So I want to save the high score in local.
So this is the event above.
If Global,Score > highscore
   -highscore set to Score.
   -Set key"savescore" to highscore   
   -t2 set to webstorage.localkey("savescore")


But it does not load. t2 shows correct but when I close the game(Preview) and open,t2 is again zero

???
   
I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Wed Feb 19, 2014 9:21 am

Well ofcourse it is..

if you are only setting it when global.score is bigger than highscore.
When you start the game again global will be lower, right?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Feb 19, 2014 9:26 am

[QUOTE=LittleStain] Well ofcourse it is..

if you are only setting it when global.score is bigger than highscore.
When you start the game again global will be lower, right?[/QUOTE]
@LittleStain
Oh,My mistake
It should be like this:
If Global,Score > highscore
   -highscore set to Score.
   -Set key"savescore" to highscore   
Every tick   
-t2 set to webstorage.localkey("savescore")
I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Wed Feb 19, 2014 9:30 am

[QUOTE=Doc Ai]

In the gameover layout, If Global,Score > highscore
highscore set to Score.
t2 set to highscore

So I want to save the high score in local.
So this is the event above.
If Global,Score > highscore
   -highscore set to Score.
   -Set key"savescore" to highscore   
   -t2 set to webstorage.localkey("savescore")

[/QUOTE]

I guess this could be the issue..
first you set highscore to score, so global.score isn't bigger than highscore for the second event.
It's not clear to me why you are using two events for this anyway.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Feb 19, 2014 10:24 am

@LittleStain
Score is the current score gained(Score gained in this play(before gameover)).Highscore is the biggest score gained ever.That's why I am saving it.
I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Wed Feb 19, 2014 10:32 am

I understand what you are trying to do.

I'm just saying the second event will not trigger if the first event is triggered, because after the first event highscore is the same as global.score, but maybe you aren't explaining your events right.


Could you please upload a screenshot of your eventsheet so we can look for where the events are flawed? LittleStain2014-02-19 10:36:26
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Feb 19, 2014 11:13 am

I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Wed Feb 19, 2014 12:29 pm

Instead of saving your highscore to webstorage every tick without any conditions you could try this:



I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Feb 19, 2014 12:40 pm

@LittleStain
Why does that work?
I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Wed Feb 19, 2014 12:43 pm

You were saving your highscore to webstorage every tick, even when score wasn't higher than highscore.

Highscore is 0 when the layout starts, so 0 was saved to webstorage.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Next

Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 26 guests