Merge pull request #92429 from Daylily-Zeleen/daylily-zeleen/add_tween_has_tweenders

Add `Tween::has_tweeners()`
This commit is contained in:
Thaddeus Crews 2026-03-12 09:03:35 -05:00
commit 020df5d452
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
3 changed files with 12 additions and 0 deletions

View file

@ -144,6 +144,12 @@
[b]Note:[/b] As it results from accumulating frame deltas, the time returned after the [Tween] has finished animating will be slightly greater than the actual [Tween] duration.
</description>
</method>
<method name="has_tweeners" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if any [Tweener] has been added to the [Tween] and the [Tween] is valid. Useful when tweeners are added dynamically and the tween can end up empty. Killing an empty tween before it starts will prevent errors.
</description>
</method>
<method name="interpolate_value" qualifiers="static">
<return type="Variant" />
<param index="0" name="initial_value" type="Variant" />

View file

@ -218,6 +218,10 @@ void Tween::kill() {
}
}
bool Tween::has_tweeners() const {
return !tweeners.is_empty();
}
bool Tween::is_running() {
return running;
}
@ -493,6 +497,7 @@ void Tween::_bind_methods() {
ClassDB::bind_method(D_METHOD("kill"), &Tween::kill);
ClassDB::bind_method(D_METHOD("get_total_elapsed_time"), &Tween::get_total_time);
ClassDB::bind_method(D_METHOD("has_tweeners"), &Tween::has_tweeners);
ClassDB::bind_method(D_METHOD("is_running"), &Tween::is_running);
ClassDB::bind_method(D_METHOD("is_valid"), &Tween::is_valid);
ClassDB::bind_method(D_METHOD("bind_node", "node"), &Tween::bind_node);

View file

@ -159,6 +159,7 @@ public:
void play();
void kill();
bool has_tweeners() const;
bool is_running();
bool is_valid();
void clear();