Topic was automatically imported from the old Question2Answer platform.
Asked By
Cakee
I currently have a button that appears and I would like to get the time between when it appears and when the user presses it. I would then like this time to be displayed through any type of text box if that is possible.
So, it sounds like you already have the button appearing. In that case…
Define a global variable to store the time the button appears:
var appear_time
At the point where the button appears, record the current time the variable. There are lots ways to do that, but here’s one…
appear_time = OS.get_ticks_msec()
Then, wire the button’s pressed() event to a handler in your script. In that handler, just calculate a delta time between the time you recorded earlier and now. Then, put that value in your some label ($Label here)…
I ended up getting an error with the $Lable.textsaying that $ should not be used. Is there another way to edit the text?
Cakee | 2020-09-07 23:25
In the example, I had a label node named Label as a direct child of my scene’s root node.
That $Label references that node. If your label is named something else or is at a different location in the scene tree, you’ll have to change the reference to match your scene.