How do I remember the highscore in the other layout?

Get help using Construct 2

Post » Sat Jun 17, 2017 1:07 pm

Hi everyone!

Again a very easy beginner's question!
I have 2 layouts, one with a start button. The game is about surviving as long as possible. So every second 1 is added the score. When the player collides with an object, the layout changes, because you have to start again from the beginning. Problem is: You should see the score you reached on this "start" layout. But it is only visibile in the layout where the current game runs.
It is frustrating, because I was able to do it some time ago and I forgot how it worked...

Thanks already for your answers!
Julia
B
12
S
3
G
1
Posts: 46
Reputation: 1,518

Post » Sat Jun 17, 2017 1:17 pm

Well if you keep the score in a global variable, you can add a text into the new layout and set the text to the global variable in the event system, nametext -> set text -> global variable. You will need to make sure to save the text first then reset the variable to 0 so player can start again, and if you like to keep the text forever even if the players closes the game you will have to save it into local storage or in an array as Json.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Sat Jun 17, 2017 1:21 pm

Hi,

You just need to use GLOBAL variables, which are visible across your entire project.
You can create one SCORE
and another BEST_SCORE

And then you can add a TEXT #1 and say something like SYSTEM every tick, SET TEXT to SCORE.
And then TEXT #2 set text to BEST_SCORE
And then if SCORE > BEST_SCORE set BEST_SCORE = SCORE

There are also lots of guides/tutorials on LOCAL / WEB storage if you want the player's computer to remember the BEST_SCORE

Good luck!
Thank you to Construct 2 for giving me the ability to create games without programming knowledge.
My games & gaming portal = DolyGames
If anyone wants to cooperate to help each other Win-Win please email me - I am always happy to discover new opportunities.
Cheers,
COSMOS
B
21
S
9
G
1
Posts: 77
Reputation: 2,181


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 11 guests