diff options
| author | Anish | 2018-04-27 01:12:50 +0530 |
|---|---|---|
| committer | Anish | 2018-04-27 01:17:20 +0530 |
| commit | f714637e58034b6340fa0725c7935a1ae29d92c0 (patch) | |
| tree | 2937ecb14ceda40ecb7fdbcee8c232a70cafadc6 | |
| parent | e5a13e26265179d9d6b477c6d744758521745123 (diff) | |
| download | godot-f714637e58034b6340fa0725c7935a1ae29d92c0.tar.gz godot-f714637e58034b6340fa0725c7935a1ae29d92c0.tar.zst godot-f714637e58034b6340fa0725c7935a1ae29d92c0.zip | |
| -rw-r--r-- | doc/classes/Timer.xml | 4 | ||||
| -rwxr-xr-x | scene/main/timer.cpp | 7 | ||||
| -rwxr-xr-x | scene/main/timer.h | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/doc/classes/Timer.xml b/doc/classes/Timer.xml index aba1b7818..c51a52d91 100644 --- a/doc/classes/Timer.xml +++ b/doc/classes/Timer.xml @@ -21,8 +21,10 @@ <method name="start"> <return type="void"> </return> + <argument index="0" name="time_sec" type="float" default="-1"> + </argument> <description> - Starts the timer. This also resets the remaining time to [code]wait_time[/code]. + Starts the timer. Sets [code]wait_time[/code] to [code]time_sec[/code] if [code]time_sec[/code] > 0. This also resets the remaining time to [code]wait_time[/code]. Note: this method will not resume a paused timer. See [method set_paused]. </description> </method> diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index ad2cdbfd0..c285694df 100755 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -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); diff --git a/scene/main/timer.h b/scene/main/timer.h index 410d98540..2f42252a7 100755 --- a/scene/main/timer.h +++ b/scene/main/timer.h @@ -64,7 +64,7 @@ public: void set_autostart(bool p_start); bool has_autostart() const; - void start(); + void start(float p_time = -1); void stop(); void set_paused(bool p_paused); |
