improve input handling

master
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

@ -52,13 +52,12 @@ window/size/resizable=false
window/size/test_width=600
window/size/test_height=1200
window/dpi/allow_hidpi=true
window/energy_saving/keep_screen_on=false
window/handheld/orientation="portrait"
window/size/width.mobile=600
window/size/height.mobile=1200
window/stretch/mode.mobile="2d"
window/stretch/aspect.mobile="expand"
window/size/width.pc=1024
window/size/height.pc=600
[filesystem]
@ -72,7 +71,6 @@ theme/custom="res://assets/taqin_theme.tres"
[input_devices]
pointing/emulate_touch_from_mouse=true
pointing/emulate_mouse_from_touch=false
[rendering]

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