Hello,
I need help with the time counting for my game
it is this:
time start at 00:00(game screen enter) - when player click on the Play button - game/time starting ( measured time spent playing level )
and when player ends the game(end game event) time stops and best time is stored in the Best time section
I have a reset button for time - when the player clicks on the Reset button time is set
to 00:00 too - this is a game reset button.
One thing I need in start time is when the player click on the Play button time start but
when it's time for example 00:30 time is automatically set 00:00 again and starts
Thanks all for help
I have this script
extends Control
var play = false
var time_start = 0
var time_now = 0
var game_time
var button_reset
var button_play
var best_time
func _ready():
set_process(true)
time_start = OS.get_unix_time()
game_time = get_node("time")
button_reset = get_node("reset")
button_play = get_node("play")
best_time = get_node("best_time")
func _process(delta):
time_now = OS.get_unix_time()
var elapsed = time_now - time_start
var minutes = elapsed / 60
var seconds = elapsed % 60
var str_elapsed = "%02d : %02d" % [minutes, seconds]
game_time.set_text(str(str_elapsed))