Created
August 15, 2020 03:19
-
-
Save DeerTears/e1f8b979314c9d7de0b5ca62676be5e3 to your computer and use it in GitHub Desktop.
time-handling singleton for Godot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node | |
var start_time = OS.get_ticks_msec() | |
func reset_time(): | |
start_time = OS.get_ticks_msec() | |
func get_time() -> int: | |
return (OS.get_ticks_msec() - start_time) | |
func convert_msec_to_timestamp(msec:int) -> String: | |
var minutes: float = floor(float(msec) / 60000) | |
# warning-ignore:narrowing_conversion | |
var remainder: int = msec - (minutes * 60000) | |
# warning-ignore:integer_division | |
var seconds: int = remainder / 1000 | |
var milli: int = remainder - (seconds * 1000) | |
return "%s:%s.%s" % [minutes, seconds, milli] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment