improve input handling

This commit is contained in:
Fabien Freling 2020-06-03 19:15:38 +02:00
parent b41ac70326
commit dc520e33f6
6 changed files with 17 additions and 4 deletions

View file

@ -82,7 +82,11 @@ func _ready() -> void:
new_game(NewGamePanel.normal_columns, NewGamePanel.normal_rows, NewGamePanel.normal_iterations)
func _input(event):
func _unhandled_input(event):
# Forward keyboard event
_gui_input(event)
func _gui_input(event):
if $AnimationPlayer.is_playing():
# Disable input during animation
return
@ -102,12 +106,16 @@ func _input(event):
#
if event.is_action_pressed("ui_up"):
move_piece(Direction.UP, 1.0)
return
if event.is_action_pressed("ui_down"):
move_piece(Direction.DOWN, 1.0)
return
if event.is_action_pressed("ui_left"):
move_piece(Direction.LEFT, 1.0)
return
if event.is_action_pressed("ui_right"):
move_piece(Direction.RIGHT, 1.0)
return
#
# Handle touch input