0 votes

Привет! Я бы хотел создать таймер в моей игре. Есть ли какой то способ сделать таймер в Label? Это можно так же использовать как время,проведенное в игре. Спасибо за все ваши подсказки!

Hey! I would like to create a timer in my game. Is there some way to make a timer in the Label? This can also be used as the time spent in the game. Thanks for all your tips!

Godot version 3.3.1
in Engine by (44 points)

1 Answer

0 votes

You can create timer by writing this code (sorry, it is c#):

Timer timer = new Timer();
AddChild(timer);
timer.Connect("timeout", this, "OnTimerTimeout");
timer.WaitTime = waitTime;
timer.OneShot = false;
timer.Start();

void OnTimerTimeout()
{
   // there should be some code to execute when the timer expires
}

For more detailed information you can look in documentation.

by (38 points)

Okay, thanks a lot anyway. But is there really no even simple alternative to the timer in GDScript?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.