handle multiple taps on hints button
This commit is contained in:
parent
852bda047c
commit
b41ac70326
|
@ -47,7 +47,7 @@ var current_touch_slide := Vector2.ZERO
|
||||||
var local_min_position := Vector2.ZERO
|
var local_min_position := Vector2.ZERO
|
||||||
var local_max_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
|
onready var hint_tween = $HintTween
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ func _input(event):
|
||||||
if $AnimationPlayer.is_playing():
|
if $AnimationPlayer.is_playing():
|
||||||
# Disable input during animation
|
# Disable input during animation
|
||||||
return
|
return
|
||||||
if _hint_active or hint_tween.is_active():
|
if hint_active or hint_tween.is_active():
|
||||||
return
|
return
|
||||||
|
|
||||||
match current_state:
|
match current_state:
|
||||||
|
@ -420,7 +420,7 @@ func new_game(columns: int, rows: int, shuffle_iterations: int) -> void:
|
||||||
# Hints
|
# Hints
|
||||||
#
|
#
|
||||||
func show_hints() -> void:
|
func show_hints() -> void:
|
||||||
_hint_active = true
|
set_hint_active(true)
|
||||||
hint_tween.remove_all()
|
hint_tween.remove_all()
|
||||||
for c in range(columns):
|
for c in range(columns):
|
||||||
for r in range(rows):
|
for r in range(rows):
|
||||||
|
@ -437,8 +437,14 @@ func discard_hints() -> void:
|
||||||
var piece: Piece = pieces[c][r]
|
var piece: Piece = pieces[c][r]
|
||||||
if piece.taquin_current_index != piece.taquin_original_index:
|
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_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_tween.start()
|
||||||
_hint_active = false
|
|
||||||
|
func get_hint_active() -> bool:
|
||||||
|
return hint_active
|
||||||
|
|
||||||
|
func set_hint_active(value: bool):
|
||||||
|
hint_active = value
|
||||||
|
|
||||||
#
|
#
|
||||||
# Signals
|
# Signals
|
||||||
|
@ -461,7 +467,8 @@ func _on_NewGamePanel_start_triggered(preferences):
|
||||||
|
|
||||||
|
|
||||||
func _on_Hints_button_down():
|
func _on_Hints_button_down():
|
||||||
show_hints()
|
if not hint_active:
|
||||||
|
show_hints()
|
||||||
|
|
||||||
func _on_Hints_button_up():
|
func _on_Hints_button_up():
|
||||||
discard_hints()
|
discard_hints()
|
||||||
|
|
Loading…
Reference in a new issue