1 @icon("node_next_indicator_icon.svg")
2 class_name DialogicNode_NextIndicator
5 ## Node that is shown when the text is fully revealed.
6 ## The default implementation allows to set an icon and animation.
9 @export var enabled := true
11 ## If true the next indicator will also be shown if the text is a question.
12 @export var show_on_questions := false
13 ## If true the next indicator will be shown even if dialogic will autocontinue.
14 @export var show_on_autoadvance := false
16 enum Animations {BOUNCE, BLINK, NONE}
18 ## What animation should the indicator do.
19 @export var animation := Animations.BOUNCE
21 var texture_rect: TextureRect
23 ## Set the image to use as the indicator.
24 @export var texture: Texture2D = preload("res://addons/dialogic/Example Assets/next-indicator/next-indicator.png") as Texture2D:
28 texture_rect.texture = texture
30 @export var texture_size := Vector2(32,32):
32 texture_size = _texture_size
33 if has_node('Texture'):
34 get_node('Texture').size = _texture_size
35 get_node('Texture').position = -_texture_size
40 func _ready() -> void:
41 add_to_group('dialogic_next_indicator')
43 # Creating TextureRect if missing
45 var icon := TextureRect.new()
47 icon.ignore_texture_size = true
48 icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
49 icon.size = texture_size
50 icon.position = -icon.size
54 texture_rect.texture = texture
57 visibility_changed.connect(_on_visibility_changed)
60 func _on_visibility_changed() -> void:
62 play_animation(animation, 1.0)
65 func play_animation(current_animation: int, time:float) -> void:
66 # clean up previous tween to prevent slipping
70 match current_animation:
72 tween = (create_tween() as Tween)
74 tween.set_parallel(false)
75 tween.set_trans(Tween.TRANS_SINE)
76 tween.set_ease(Tween.EASE_IN_OUT)
79 tween.tween_property(self, 'position', Vector2(0,distance), time*0.3).as_relative()
80 tween.tween_property(self, 'position', - Vector2(0,distance), time*0.3).as_relative()
82 tween = (create_tween() as Tween)
83 tween.set_parallel(false)
84 tween.set_trans(Tween.TRANS_SINE)
85 tween.set_ease(Tween.EASE_IN_OUT)
88 tween.tween_property(self, 'modulate:a', 0, time*0.3)
89 tween.tween_property(self, 'modulate:a', 1, time*0.3)