]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/Character/DefaultAnimations/fade_down_in_out.gd
Initial Godot project with Dialogic 2.0-Alpha-17
[wolf-seeking-sheep.git] / addons / dialogic / Modules / Character / DefaultAnimations / fade_down_in_out.gd
1 extends DialogicAnimation
2
3 func animate() -> void:
4         var tween := (node.create_tween() as Tween)
5
6         var start_height: float = base_position.y - node.get_viewport().size.y / 5
7         var end_height := base_position.y
8
9         var start_modulation := 0.0
10         var end_modulation := 1.0
11
12         if is_reversed:
13                 end_height = start_height
14                 start_height = base_position.y
15                 end_modulation = 0.0
16                 start_modulation = 1.0
17
18         node.position.y = start_height
19
20         tween.set_ease(Tween.EASE_OUT)
21         tween.set_trans(Tween.TRANS_SINE)
22         tween.set_parallel()
23
24         var end_postion := Vector2(base_position.x, end_height)
25         tween.tween_property(node, "position", end_postion, time)
26
27         var property := get_modulation_property()
28
29         var original_modulation: Color = node.get(property)
30         original_modulation.a = start_modulation
31         node.set(property, original_modulation)
32         var modulation_alpha := property + ":a"
33
34         tween.tween_property(node, modulation_alpha, end_modulation, time)
35
36         await tween.finished
37         finished_once.emit()
38
39
40 func _get_named_variations() -> Dictionary:
41         return {
42                 "fade in down": {"reversed": false, "type": AnimationType.IN},
43                 "fade out up": {"reversed": true, "type": AnimationType.OUT},
44         }