]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/Character/DefaultAnimations/bounce_in_out.gd
Initial Godot project with Dialogic 2.0-Alpha-17
[wolf-seeking-sheep.git] / addons / dialogic / Modules / Character / DefaultAnimations / bounce_in_out.gd
1 extends DialogicAnimation
2
3
4 func animate() -> void:
5         var tween := (node.create_tween() as Tween)
6
7         var end_scale: Vector2 = node.scale
8         var end_modulate_alpha := 1.0
9         var modulation_property := get_modulation_property()
10
11         if is_reversed:
12                 end_scale = Vector2(0, 0)
13                 end_modulate_alpha = 0.0
14
15         else:
16                 node.scale = Vector2(0, 0)
17                 var original_modulation: Color = node.get(modulation_property)
18                 original_modulation.a = 0.0
19                 node.set(modulation_property, original_modulation)
20
21
22         tween.set_ease(Tween.EASE_IN_OUT)
23         tween.set_trans(Tween.TRANS_SINE)
24         tween.set_parallel()
25
26         (tween.tween_property(node, "scale", end_scale, time)
27                 .set_trans(Tween.TRANS_SPRING)
28                 .set_ease(Tween.EASE_OUT))
29         tween.tween_property(node, modulation_property + ":a", end_modulate_alpha, time)
30
31         await tween.finished
32         finished_once.emit()
33
34
35 func _get_named_variations() -> Dictionary:
36         return {
37                 "bounce in": {"reversed": false, "type": AnimationType.IN},
38                 "bounce out": {"reversed": true, "type": AnimationType.OUT},
39         }