[Solved] Show total time at end of level on "You Won" screen?

I want show total time at end of level on “You Won” screen, along with displaying the player’s best time on that level so far. I want to do this at the end of each level.

I’m still new to gave dev, but I assume I’m going to need to keep track of all the different times in variables. But how to implement all of this is beyond me right now. I managed to get the timer to display on screen during the game play, and have it set to pause the timer when the player collides with the sprite at the end of the level. What else do I need to do?


1 Like

Add a timer then use an Extension to convert the elapsed time into HH:MM:SS

Look into my templates in the Socceralia I use that method to show the time remaining of each half. In this case you need to do is to store the time maybe in a variable or just start the conversion at the begin of the scene then when the level is finished stop or pause the timer.

I already did that to display the time during gameplay.

I don’t know what that means. What is Socceralia?

Look here

Oh, it’s a game.
Thanks for the link, but I looked through it, and there is so much to it, I have no idea how to find the part you are suggesting I look at. Great work on making such an elaborate game though.

I’m not sure you understood my question. I have multiple levels in a game. At the end of each level, there is a screen saying “You Won” and on that screen I want to display the time it took to complete that level, along with your quickest time so far. I don’t see anything like that in your game.

Sure that’s what I’m suggesting to do
At the begin of the scene add a timer name it “LevelTime” then during all the level that timer will be running so create a text object to display the time and use the extension Time formatting to display the elapsed time of the timer “LevelTime”
Here look

I watched the video, and maybe I’m missing something that you showing.

I already have a working timer on display in the game level, and I am already using that extension to do it. I don’t think there was anything else explained in that video than what I had already done.

The part I can’t figure out is how to get the next screen to display it, nor how to keep track of and display the best time done on that level so far.

If you’re changing the scene you need to store the elapsed time into a Global variable the same way you use the time formatting to get the time but instead of show the value just save it into a variable then even if you change the scene the global will keep the stored value of the leveltimer.
If you show me the events logic will be easy for me to understand what’s going on there.


I assumed it was something with variables, but I’ve only been trying to learn making games for less than 2 months, so variables still confuse me. What I mean is that I don’t understand how to implement the variables needed.

So I don’t have any event logic for showing the latest time or best time on the winning screen, yet.

Try this way to store the timer value into a variable just choose which type you need scene or global variable.

Will I need to have a different name for each level’s timer variable?

I tried to do what you suggested, but couldn’t find “change the text of a scene variable”.

You want the action called “String of a scene variable”. “String” means text/words, “Value” means a number.

I tried this:

{“000kind”:“GDEVELOP_EventsAndInstructions_CLIPBOARD_KIND-jsBdHbLy912y8Rc”,“content”:{“eventsList”:[],“eventsCount”:0,“actionsList”:[{“type”:{“inverted”:false,“value”:“TextObject::String”},“parameters”:[“Timer”,"=","“Time: " +VariableString(totalTime)”],“subInstructions”:[]}],“actionsCount”:1,“conditionsList”:[],“conditionsCount”:0}}

Is that the same as what you are saying?

On the scene that I need the time from, I put:


I still am not getting the total time showing up on the “You Win” page though. Any idea what I did wrong?

Can you please take a screenshot of your events and share here so we can help you better.

In the level that I am timing I have this at the end:

Then in the “You Win” scene I have:

As I suspected you’re setting a scene variable so when you change the scene the value of totalTime is going to be reset.
You have two ways to do this save the Time in Storage then when you change the scene to TitleWin use
1 - Read from Storage. and reassign the value to the variable.

2 - Use a global variable to store the TimeFromStart() if you do not reset the Global variable at the begin of the scene then the value will persist.

Another approach is for you to add an external layout for the TitleWin so when the player collides with Finish, just show the external layout TitleWin then the scene variable will work because you’re not changing the scene just showing/hiding the external layout.

Another is like this
When the player collides with finish you save the variable in Storage like the first event
The second event is the begin of the scene in your TitleWin scene, so at the begin Read the saved Storage and assign to the variable TimeFromStart then show the text, note the TimeFromStart is a number, so you probably need the extension time formatter to convert that number into a readable time like 00:00:00

Of the different ways you showed, I would think that saving the time would work best because I want to also keep the high score for each level.

Do I need to have a unique timer and global variable name for each level? How do I store and display a “best time for this level”?

You can save into Storage like total_time_level_1, total_time_level_2, etc., so it’s easy later to display the save data just use a temp scene var to store all the total_time_level_1, 2,3 or you can use a read all Storage to a scene variable and then parse as JSON or use Structure variables to save the different values from storage into that structure
Look in the inventory examples there is a lot of advanced Storage samples.

There is no need for you to make unique timers because you are chaging the scene so at the begin of the level the timer will be reset, and use scene variables and do a reset of timeFromStart = 0 at the begin of the level.

Your level logic will be
Begin of the scene
Reset timer “TimeFromStart”
Scene variable TimeFromStart = 0

  • Play the level
    – Player collides Finish
    – Set variable TimeFromStart = TimeFromStart()
    – Write TimeFromStart in Storage
    TIP: Here is the important part you save into Storage like
    Write Variable(TimeFromStart) in “time_level_1” of storage"save"
    So in level 2 save time_level_2 and so on.
    Show your Win Scene
    Read Storage
    Assign the variable TimeFromStart
    Display the time in a text object.

Is a good practice to also save in Storage the current level and the max level reached so you can control which level the player is playing. So if you have a World of levels and the player can play 1 or 2 or 20 and revisit the level to get better scores or better time.

To control the level in Storage I do this.

Then if I need to update some score or stars or level time I do this.

Thank you for explaining that. It’s way over my head, but I will try to get through it by the end of tomorrow and let you know how it goes.

1 Like