Skip to content

Commit 4e82bde

Browse files
committed
Kill subtweens when their parent tween is killed
1 parent d7cc121 commit 4e82bde

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

scene/animation/tween.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ void Tween::kill() {
200200
running = false; // For the sake of is_running().
201201
valid = false;
202202
dead = true;
203+
204+
// Kill all subtweens of this tween.
205+
for (List<Ref<Tweener>> &tweener : tweeners) {
206+
for (Ref<Tweener> &indiv_tweener : tweener) {
207+
SubtweenTweener *as_subtween_tweener = Object::cast_to<SubtweenTweener>(indiv_tweener.ptr());
208+
if (as_subtween_tweener) {
209+
as_subtween_tweener->subtween->kill();
210+
}
211+
}
212+
}
203213
}
204214

205215
bool Tween::is_running() {

0 commit comments

Comments
 (0)