How to measure the time on a level.
dashnevada
Member Posts: 58
Hello
I need a little help, I want to record the time it took for the user to finish the level then display it on a screen at the end.
I tried using game.time but that measures the time the entire game has been open. When I chance the scene it doesn't reset.
Any idea how you do this?
thank you very much
I need a little help, I want to record the time it took for the user to finish the level then display it on a screen at the end.
I tried using game.time but that measures the time the entire game has been open. When I chance the scene it doesn't reset.
Any idea how you do this?
thank you very much
Comments
Have a rule when attribute record time is true every, .1 seconds change attribute leveltime to leveltime+1
When you finish the level change record time to false and wherever you want to display the time just have a display text behavior and display attribute level time.
Then when you change to the next level change attribute leveltime to 0 and change recordtime to true.
If you want to save the times your gonna have to have anther attribute for each level and change it to leveltime before you change to the next scene, and if you want to display it in digital clock format youll have to watch tshirts display time video in the cookbook and in the display text where you dispay the time, use the expresssion he uses
1 gameAttribute real type named startTime
1 gameAttribute real type named endTime
additional real game.Attributes for level1Time; level2Time; etc. (for each level)
in your code (when you initiate changeScene) also changeAttribute game.startTime To: game.Time
Rule when the goal of the level is met...
--changeAttribute game.endTime To: game.Time
--changeAttribute level1Time To: game.endTime-game.startTime
(you can save that attribute and also show on your tracking/scoring scene Display Text it)
of course that gives you seconds...not minutes... you divide seconds by seconds per minutes (ex:120/60) to get minutes ...as John says watch Tshirtbooth's video for the function "floor" (rounding down values...) and division parameters...
MH
Thx again