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?
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.
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”
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.
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
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
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.