You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Improve some Tween internals
This commit is contained in:
@@ -60,7 +60,7 @@ void Tweener::_bind_methods() {
|
|||||||
ADD_SIGNAL(MethodInfo("finished"));
|
ADD_SIGNAL(MethodInfo("finished"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tween::start_tweeners() {
|
void Tween::_start_tweeners() {
|
||||||
if (tweeners.is_empty()) {
|
if (tweeners.is_empty()) {
|
||||||
dead = true;
|
dead = true;
|
||||||
ERR_FAIL_MSG("Tween without commands, aborting.");
|
ERR_FAIL_MSG("Tween without commands, aborting.");
|
||||||
@@ -71,6 +71,15 @@ void Tween::start_tweeners() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Tween::_stop_internal(bool p_reset) {
|
||||||
|
running = false;
|
||||||
|
if (p_reset) {
|
||||||
|
started = false;
|
||||||
|
dead = false;
|
||||||
|
total_time = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ref<PropertyTweener> Tween::tween_property(Object *p_target, NodePath p_property, Variant p_to, double p_duration) {
|
Ref<PropertyTweener> Tween::tween_property(Object *p_target, NodePath p_property, Variant p_to, double p_duration) {
|
||||||
ERR_FAIL_NULL_V(p_target, nullptr);
|
ERR_FAIL_NULL_V(p_target, nullptr);
|
||||||
ERR_FAIL_COND_V_MSG(!valid, nullptr, "Tween invalid. Either finished or created outside scene tree.");
|
ERR_FAIL_COND_V_MSG(!valid, nullptr, "Tween invalid. Either finished or created outside scene tree.");
|
||||||
@@ -135,14 +144,11 @@ void Tween::append(Ref<Tweener> p_tweener) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Tween::stop() {
|
void Tween::stop() {
|
||||||
started = false;
|
_stop_internal(true);
|
||||||
running = false;
|
|
||||||
dead = false;
|
|
||||||
total_time = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tween::pause() {
|
void Tween::pause() {
|
||||||
running = false;
|
_stop_internal(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tween::play() {
|
void Tween::play() {
|
||||||
@@ -278,7 +284,7 @@ bool Tween::step(double p_delta) {
|
|||||||
current_step = 0;
|
current_step = 0;
|
||||||
loops_done = 0;
|
loops_done = 0;
|
||||||
total_time = 0;
|
total_time = 0;
|
||||||
start_tweeners();
|
_start_tweeners();
|
||||||
started = true;
|
started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +325,7 @@ bool Tween::step(double p_delta) {
|
|||||||
} else {
|
} else {
|
||||||
emit_signal(SNAME("loop_finished"), loops_done);
|
emit_signal(SNAME("loop_finished"), loops_done);
|
||||||
current_step = 0;
|
current_step = 0;
|
||||||
start_tweeners();
|
_start_tweeners();
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (loops <= 0 && Math::is_equal_approx(rem_delta, initial_delta)) {
|
if (loops <= 0 && Math::is_equal_approx(rem_delta, initial_delta)) {
|
||||||
if (!potential_infinite) {
|
if (!potential_infinite) {
|
||||||
@@ -332,7 +338,7 @@ bool Tween::step(double p_delta) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
start_tweeners();
|
_start_tweeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,8 @@ private:
|
|||||||
typedef real_t (*interpolater)(real_t t, real_t b, real_t c, real_t d);
|
typedef real_t (*interpolater)(real_t t, real_t b, real_t c, real_t d);
|
||||||
static interpolater interpolaters[TRANS_MAX][EASE_MAX];
|
static interpolater interpolaters[TRANS_MAX][EASE_MAX];
|
||||||
|
|
||||||
void start_tweeners();
|
void _start_tweeners();
|
||||||
|
void _stop_internal(bool p_reset);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|||||||
Reference in New Issue
Block a user