Force final value at the end of Tween
This commit is contained in:
parent
f0407ad14d
commit
d48dea7158
2 changed files with 10 additions and 3 deletions
|
@ -741,12 +741,12 @@ bool PropertyTweener::step(float &r_delta) {
|
|||
}
|
||||
|
||||
float time = MIN(elapsed_time - delay, duration);
|
||||
target_instance->set_indexed(property, tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type));
|
||||
|
||||
if (time < duration) {
|
||||
target_instance->set_indexed(property, tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type));
|
||||
r_delta = 0;
|
||||
return true;
|
||||
} else {
|
||||
target_instance->set_indexed(property, final_val);
|
||||
finished = true;
|
||||
r_delta = elapsed_time - delay - duration;
|
||||
emit_signal(SNAME("finished"));
|
||||
|
@ -895,8 +895,13 @@ bool MethodTweener::step(float &r_delta) {
|
|||
return true;
|
||||
}
|
||||
|
||||
Variant current_val;
|
||||
float time = MIN(elapsed_time - delay, duration);
|
||||
Variant current_val = tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type);
|
||||
if (time < duration) {
|
||||
current_val = tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type);
|
||||
} else {
|
||||
current_val = final_val;
|
||||
}
|
||||
const Variant **argptr = (const Variant **)alloca(sizeof(Variant *));
|
||||
argptr[0] = ¤t_val;
|
||||
|
||||
|
@ -938,6 +943,7 @@ MethodTweener::MethodTweener(Callable p_callback, Variant p_from, Variant p_to,
|
|||
callback = p_callback;
|
||||
initial_val = p_from;
|
||||
delta_val = tween->calculate_delta_value(p_from, p_to);
|
||||
final_val = p_to;
|
||||
duration = p_duration;
|
||||
}
|
||||
|
||||
|
|
|
@ -274,6 +274,7 @@ private:
|
|||
Ref<Tween> tween;
|
||||
Variant initial_val;
|
||||
Variant delta_val;
|
||||
Variant final_val;
|
||||
Callable callback;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue