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

@ -20,6 +20,7 @@ text = "Press Me"
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
[node name="Button" type="Button" parent="."]
anchor_right = 1.0

View file

@ -13,6 +13,10 @@ func _notification(what):
save_game()
get_tree().quit() # default behavior
func _gui_input(event):
# Forward events to taquin so we can swipe from anywhere
taquin._gui_input(event)
func layout_reflow():
if container == null:
return

View file

@ -258,6 +258,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
margin_right = 160.0
margin_bottom = 160.0
mouse_filter = 2
__meta__ = {
"_edit_use_anchors_": false
}

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

View file

@ -64,6 +64,7 @@ margin_left = -300.0
margin_top = -300.0
margin_right = 300.0
margin_bottom = 300.0
mouse_filter = 2
color = Color( 0.12549, 0.235294, 0.337255, 1 )
__meta__ = {
"_edit_use_anchors_": false