Add get_loops_left() function to Tween
Implements godotengine/godot-proposals#5141. Adds a new get_loops_left() function to Tween, allowing developers to reason about how many times a tweening sequence will repeat and whether to expect finished or loop_finished as the next signal. Co-authored-by: Tomek <kobewi4e@gmail.com>
This commit is contained in:
parent
161d028ae8
commit
4cb2085543
3 changed files with 16 additions and 0 deletions
|
|
@ -228,6 +228,14 @@ Ref<Tween> Tween::set_loops(int p_loops) {
|
|||
return this;
|
||||
}
|
||||
|
||||
int Tween::get_loops_left() const {
|
||||
if (loops <= 0) {
|
||||
return -1; // Infinite loop.
|
||||
} else {
|
||||
return loops - loops_done;
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Tween> Tween::set_speed_scale(float p_speed) {
|
||||
speed_scale = p_speed;
|
||||
return this;
|
||||
|
|
@ -442,6 +450,7 @@ void Tween::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method(D_METHOD("set_parallel", "parallel"), &Tween::set_parallel, DEFVAL(true));
|
||||
ClassDB::bind_method(D_METHOD("set_loops", "loops"), &Tween::set_loops, DEFVAL(0));
|
||||
ClassDB::bind_method(D_METHOD("get_loops_left"), &Tween::get_loops_left);
|
||||
ClassDB::bind_method(D_METHOD("set_speed_scale", "speed"), &Tween::set_speed_scale);
|
||||
ClassDB::bind_method(D_METHOD("set_trans", "trans"), &Tween::set_trans);
|
||||
ClassDB::bind_method(D_METHOD("set_ease", "ease"), &Tween::set_ease);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue