Help me to display a high score <3

Get help using Construct 2

Post » Wed Jun 21, 2017 12:16 am

Hello guys!

I've now published my infinite runner "Kuatia" on Google Play Store (check it out here: https://play.google.com/store/apps/details?id=com.bds.kuatia)

I want to add a high score feature that shows the player their highest score at the end of their run, though. I already have one in place that shows the score for the current run.

But I want to display their best, too. I'm using the LocalStorage plugin but I can't seem to get it to display.

I've read the tutorials but I get lost when it's time to replace the HighScore value with the current value if it's higher. I can't get anything to display :( What am I doing wrong?

Attached is a screenshot of my events.

Image
high res image hosting

Any help is appreciated <3
B
15
S
5
Posts: 78
Reputation: 1,173

Post » Wed Jun 21, 2017 12:17 am

PS: I have TotalDistance and HighScore as global variables in my main game layout. This is my game over layout.
B
15
S
5
Posts: 78
Reputation: 1,173

Post » Thu Jun 22, 2017 5:54 pm

Can nobody help? :(

Give your boyo a hand! It really is quite a good little game, and I have really tried to implement it on my own.
B
15
S
5
Posts: 78
Reputation: 1,173

Post » Thu Jun 22, 2017 6:13 pm

Hmm, so the problem is: You want to change the highscore if it is higher than the previous value.
Well, that's quite simple.

I don't know how does your game work, but let's say at the end of the run you calculate the Highscore. Simply add a condition to check if the current score is higher than the last one.

I can see you already have this event but it needs to be at the end of the run when you calculate the highscore. In the same event, save the Highscore value in LocalStorage.
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Thu Jun 22, 2017 6:20 pm

@RobertMKD, what I'm trying to do is display both current score (which I already have working) and high score (which is saved to LocalStorage). And then compare current score with high score to see if it's higher, and if it is, then update the high score.

I can now post links so here's my capx file: https://www.mediafire.com/?rez44b8mhmtyd6f

Any help is appreciated :D
B
15
S
5
Posts: 78
Reputation: 1,173

Post » Thu Jun 22, 2017 6:57 pm

Okay, so I have found several mistakes.

First, you were checking for the LocalStorage data at the start of the "Game Over" layout. The data from LocalStorage is best to be updated at the start of the game (the first layout):
Image

Second, here you were setting the "high_score" item to a string "TotalDistance", I've done this:
Image

Third, you are reseting ALL global variables, including the high score, at the start of the "Game" layout. That way, you are actually erasing the highscore data which you need to display later.
Instead of reseting all global variables, simply return back to 0 those that must be reseted, as an example I have set CurrentDistance to 0, but I guess there's more that need to be reseted:
Image

So, here's what I've got now:
Image

30 is the highscore, while 24 is my new score..

Hope this helped


edit: in the first image, the 'on item missing' event is not really necessary, so delete it..
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Thu Jun 22, 2017 7:09 pm

@RobertMKD, that's AWESOME! Thank you! Is there any chance that you could provide me with this modified capx file? I know I'd be copying off your work a little bit, but it'd save me some time (while I work on my day job xD).

Much appreciated either way! <3 Thanks!
B
15
S
5
Posts: 78
Reputation: 1,173

Post » Thu Jun 22, 2017 7:14 pm

Sure, you can download it from here https://www.dropbox.com/s/3iicak6lvxz4w1m/kuatia_for_testing.capx?dl=0

By the way, it's a nice design you've got there :)
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Thu Jun 22, 2017 7:19 pm

@RobertMKD thank you very much, man! And thank you for the comment on the design. I worked hard on it :) Good to know it's appreciated.
B
15
S
5
Posts: 78
Reputation: 1,173


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests