diff --git a/src/Taquin.gd b/src/Taquin.gd index ce43750..0b2e214 100644 --- a/src/Taquin.gd +++ b/src/Taquin.gd @@ -47,7 +47,7 @@ var current_touch_slide := Vector2.ZERO var local_min_position := Vector2.ZERO var local_max_position := Vector2.ZERO -var _hint_active := false +var hint_active := false setget set_hint_active, get_hint_active onready var hint_tween = $HintTween @@ -86,7 +86,7 @@ func _input(event): if $AnimationPlayer.is_playing(): # Disable input during animation return - if _hint_active or hint_tween.is_active(): + if hint_active or hint_tween.is_active(): return match current_state: @@ -420,7 +420,7 @@ func new_game(columns: int, rows: int, shuffle_iterations: int) -> void: # Hints # func show_hints() -> void: - _hint_active = true + set_hint_active(true) hint_tween.remove_all() for c in range(columns): for r in range(rows): @@ -437,8 +437,14 @@ func discard_hints() -> void: var piece: Piece = pieces[c][r] if piece.taquin_current_index != piece.taquin_original_index: hint_tween.interpolate_property(piece, "position", piece.position, piece.taquin_current_position, 0.2) + hint_tween.interpolate_callback(self, 0.2, "set_hint_active", false) hint_tween.start() - _hint_active = false + +func get_hint_active() -> bool: + return hint_active + +func set_hint_active(value: bool): + hint_active = value # # Signals @@ -461,7 +467,8 @@ func _on_NewGamePanel_start_triggered(preferences): func _on_Hints_button_down(): - show_hints() + if not hint_active: + show_hints() func _on_Hints_button_up(): discard_hints()