1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Allows setting the Timer wait_time in start method.

Allows shortening the two line method of Timer.set_wait_time
followed by Timer.start set wait_time as a parameter to
Timer.start. Also modifies the class documentation.

Fixes: #18107
This commit is contained in:
Anish
2018-04-27 01:12:50 +05:30
parent e5a13e2626
commit f714637e58
3 changed files with 9 additions and 4 deletions

View File

@@ -107,7 +107,10 @@ bool Timer::has_autostart() const {
return autostart;
}
void Timer::start() {
void Timer::start(float p_time) {
if (p_time > 0) {
set_wait_time(p_time);
}
time_left = wait_time;
_set_process(true);
}
@@ -185,7 +188,7 @@ void Timer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_autostart", "enable"), &Timer::set_autostart);
ClassDB::bind_method(D_METHOD("has_autostart"), &Timer::has_autostart);
ClassDB::bind_method(D_METHOD("start"), &Timer::start);
ClassDB::bind_method(D_METHOD("start", "time_sec"), &Timer::start, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("stop"), &Timer::stop);
ClassDB::bind_method(D_METHOD("set_paused", "paused"), &Timer::set_paused);