Changes on how animation plays on frame tags

If the animation starts playing on a frame outside a tag, the animation will not limit itself to the tags later on as it plays. The animation will play only on a tag, if it started on a frame which has that tag. I also made it react to frame and tag changes, if they happen while the animation is running.

I also added a play_animation() method in AnimationTimeline.gd, to reduce duplicate code found in _on_PlayForward_toggled() and _on_PlayBackwards_toggled()
This commit is contained in:
OverloadedOrama 2020-04-19 20:39:08 +03:00
parent 81ce4f68b1
commit ba2b8aae91
2 changed files with 82 additions and 42 deletions

View file

@ -539,6 +539,17 @@ func canvases_changed(value : Array) -> void:
layers[i][3].add_child(frame_button)
# This is useful in case tagged frames get deleted DURING the animation is playing
# otherwise, this code is useless in this context, since these values are being set
# when the play buttons get pressed, anyway
animation_timeline.first_frame = 0
animation_timeline.last_frame = canvases.size() - 1
if play_only_tags:
for tag in animation_tags:
if current_frame + 1 >= tag[2] && current_frame + 1 <= tag[3]:
animation_timeline.first_frame = tag[2] - 1
animation_timeline.last_frame = min(canvases.size() - 1, tag[3] - 1)
func clear_canvases() -> void:
for child in canvas_parent.get_children():
if child is Canvas:
@ -694,6 +705,17 @@ func animation_tags_changed(value : Array) -> void:
tag_c.get_node("Line2D").points[2] = Vector2(tag_c.rect_min_size.x, 0)
tag_c.get_node("Line2D").points[3] = Vector2(tag_c.rect_min_size.x, 32)
# This is useful in case tags get modified DURING the animation is playing
# otherwise, this code is useless in this context, since these values are being set
# when the play buttons get pressed, anyway
animation_timeline.first_frame = 0
animation_timeline.last_frame = canvases.size() - 1
if play_only_tags:
for tag in animation_tags:
if current_frame + 1 >= tag[2] && current_frame + 1 <= tag[3]:
animation_timeline.first_frame = tag[2] - 1
animation_timeline.last_frame = min(canvases.size() - 1, tag[3] - 1)
func update_hint_tooltips() -> void:
var root = get_tree().get_root()