1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Add tween_subtween method for nesting Tweens

No actual functionality yet

Actual subtween functionality implemented

Added documentation for Tween.tween_subtween and SubtweenTweener

Implemented some additional functions

`set_ease`, `set_trans`, and `set_delay`
Documentation only for `set_delay` so far, since I have tested it

Removed set_ease and set_trans

Upon further investigation, the way they are implemented for Tween doesn't appear to work here

Fixed indentation in documentation

Reset subtween when parent loops

Fix return type of `SubtweenTweener.set_delay`

Add notes to documentation

Apply suggestions from code review

Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>

Apply some suggested changes

- Remove excessive documentation
- Add Tween constructor that takes in SceneTree
- Make `SubtweenTweener::subtween` public so that `Tween` doesn't have to be a friend class

Remove unneeded friend class SceneTree

Remove superfluous documentation describing subtween behavior

Apply suggestions from code review

Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>

Apply suggestions from code review

Co-authored-by: Thaddeus Crews <repiteo@outlook.com>

Apply suggestions from code review

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>

Early return from `tween_subtween` if the subtween is `null`
This commit is contained in:
Malcolm Anderson
2024-10-28 22:30:33 -07:00
parent 2582793d40
commit be266138d7
7 changed files with 149 additions and 1 deletions

View File

@@ -35,6 +35,7 @@
class Tween;
class Node;
class SceneTree;
class Tweener : public RefCounted {
GDCLASS(Tweener, RefCounted);
@@ -60,6 +61,7 @@ class PropertyTweener;
class IntervalTweener;
class CallbackTweener;
class MethodTweener;
class SubtweenTweener;
class Tween : public RefCounted {
GDCLASS(Tween, RefCounted);
@@ -109,6 +111,7 @@ private:
EaseType default_ease = EaseType::EASE_IN_OUT;
ObjectID bound_node;
SceneTree *parent_tree = nullptr;
Vector<List<Ref<Tweener>>> tweeners;
double total_time = 0;
int current_step = -1;
@@ -145,6 +148,7 @@ public:
Ref<IntervalTweener> tween_interval(double p_time);
Ref<CallbackTweener> tween_callback(const Callable &p_callback);
Ref<MethodTweener> tween_method(const Callable &p_callback, const Variant p_from, Variant p_to, double p_duration);
Ref<SubtweenTweener> tween_subtween(const Ref<Tween> &p_subtween);
void append(Ref<Tweener> p_tweener);
bool custom_step(double p_delta);
@@ -187,6 +191,7 @@ public:
Tween();
Tween(bool p_valid);
Tween(SceneTree *p_parent_tree);
};
VARIANT_ENUM_CAST(Tween::TweenPauseMode);
@@ -305,4 +310,24 @@ private:
Ref<RefCounted> ref_copy;
};
class SubtweenTweener : public Tweener {
GDCLASS(SubtweenTweener, Tweener);
public:
Ref<Tween> subtween;
void start() override;
bool step(double &r_delta) override;
Ref<SubtweenTweener> set_delay(double p_delay);
SubtweenTweener(const Ref<Tween> &p_subtween);
SubtweenTweener();
protected:
static void _bind_methods();
private:
double delay = 0;
};
#endif // TWEEN_H