Player timer/score
vlaso
Member, PRO Posts: 19
I'm trying to calculate the time a player survives as the score. I currently have 2 attributes, StartTime and EndTime in which consult game.Time. However, when the game finishes, the timer continues and I am having troubles stopping it and reseting it.
Do you know a way of stopping it?
Do you know how to reset it?
If not, do you know another way of achieving a score system like this?
Thank you, sorry for all the questions.
Comments
Change attribute game.StartTime to game.Time
When [game over condition]
Change attribute game.EndTime to game.Time
Change attribute game.Score to game.EndTime-game.StartTime
Otherwise
Constrain attribute game.Score to game.Time-game.StartTime
You'll want to use round() or roundTo() to round those expressions to some number of digits.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
This is just for displaying the score, right? This doesnt stop or reset the time?
Is it possible maybe to get a demo of this? just to help me understand it more. Thankyou.
No, it stops and resets the time, too. Just put that code into an actor and then use another actor on your game over scene to display game.Score.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Posting your image here:
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
You'll notice that your second Change Attribute behavior has a blank expression instead of:
Change attribute game.EndTime to game.Time
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I have added that to a pause button, but it stops the timer for a split second before continuing when unpaused. When unpaused it jumps to the time it would have been, like it was never paused...
Eg. Paused at 1.0sec, Unpause and the timer is 10.0sec.
How can I have it so the timer stops completely, and then starts from the exact time paused (1.0sec)
For that you'd have to use a custom timer, something like Timer every 0.1 seconds change attribute game.customTime (real) to game.customTime + 0.1. You would use that attribute in place of game.Time in your rules. To reset the timer, you would change attribute game.customTime to 0.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User