Add tapping via double clicking
This commit is contained in:
parent
9648170a9c
commit
2b6b0bde35
2 changed files with 104 additions and 80 deletions
|
@ -7,6 +7,8 @@ signal card_unselected()
|
|||
signal card_picked()
|
||||
signal card_dropped()
|
||||
|
||||
var clicked := false
|
||||
var exhausted := false
|
||||
var lifted := false
|
||||
export var cardID := ""
|
||||
export var playerID := 0
|
||||
|
@ -25,7 +27,13 @@ func _mouse_blur():
|
|||
emit_signal("card_unselected")
|
||||
|
||||
func _input_event(camera, event, click_position, click_normal, shape_idx):
|
||||
if lifted and event is InputEventMouseMotion:
|
||||
if clicked and event is InputEventMouseMotion:
|
||||
if not lifted:
|
||||
animation.play("lift")
|
||||
if inHand:
|
||||
animation.advance(1.0)
|
||||
emit_signal("card_picked")
|
||||
lifted = true
|
||||
var origin: Vector3 = camera.project_ray_origin(event.position)
|
||||
var direction: Vector3 = camera.project_ray_normal(event.position)
|
||||
if inHand:
|
||||
|
@ -35,16 +43,23 @@ func _input_event(camera, event, click_position, click_normal, shape_idx):
|
|||
var t: float = (-camera.transform.origin).dot(Vector3.UP) / denom;
|
||||
transform.origin = origin + direction * t
|
||||
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT:
|
||||
if event.pressed:
|
||||
animation.play("lift")
|
||||
if inHand:
|
||||
animation.advance(1.0)
|
||||
emit_signal("card_picked")
|
||||
lifted = true
|
||||
else:
|
||||
# Update click status
|
||||
clicked = event.pressed
|
||||
|
||||
# Check for card dropped
|
||||
if not clicked and lifted:
|
||||
if inHand:
|
||||
animation.play("drop")
|
||||
else:
|
||||
animation.play_backwards("lift")
|
||||
emit_signal("card_dropped")
|
||||
lifted = false
|
||||
|
||||
# Check double click
|
||||
if event.doubleclick and not lifted and not animation.is_playing():
|
||||
if exhausted:
|
||||
animation.play_backwards("tap")
|
||||
exhausted = false
|
||||
else:
|
||||
animation.play("tap")
|
||||
exhausted = true
|
|
@ -8,7 +8,7 @@
|
|||
[sub_resource type="BoxShape" id=1]
|
||||
extents = Vector3( 0.367502, 0.0309108, 0.49861 )
|
||||
|
||||
[sub_resource type="Animation" id=8]
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "blur"
|
||||
length = 0.1
|
||||
step = 0.01
|
||||
|
@ -23,7 +23,7 @@ tracks/0/keys = {
|
|||
"times": PoolRealArray( 0, 0.1 )
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=9]
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "drop"
|
||||
length = 0.1
|
||||
step = 0.05
|
||||
|
@ -40,66 +40,8 @@ tracks/0/keys = {
|
|||
"values": [ Vector3( 0, 0.15, 0 ), Vector3( 0, 0, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:rotation_degrees")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.3 ),
|
||||
"transitions": PoolRealArray( 0.466516, 2.37841 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, -90, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "focus"
|
||||
length = 0.1
|
||||
step = 0.01
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/path = NodePath(".:translation:z")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"points": PoolRealArray( 0, -0.0120957, 0.235858, 0.0120957, -0.235858, -0.2, -0.0266453, -0.000916421, 0.0266453, 0.000916421 ),
|
||||
"times": PoolRealArray( 0, 0.1 )
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
resource_name = "lift"
|
||||
length = 0.3
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:translation")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.3 ),
|
||||
"transitions": PoolRealArray( 0.965936, 0.870551 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0.15, 0 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath(".:rotation_degrees")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 0.05, 0.15, 0.3 ),
|
||||
"transitions": PoolRealArray( 0.392292, 0.392292, 1, 0.329877 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ), Vector3( 0, 0, 9.73853 ), Vector3( 0, 0, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
resource_name = "flip"
|
||||
length = 0.5
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
|
@ -127,9 +69,76 @@ tracks/1/keys = {
|
|||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0, 180 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="PlaneMesh" id=6]
|
||||
[sub_resource type="Animation" id=5]
|
||||
length = 0.1
|
||||
step = 0.01
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/path = NodePath(".:translation:z")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"points": PoolRealArray( 0, -0.0120957, 0.235858, 0.0120957, -0.235858, -0.2, -0.0266453, -0.000916421, 0.0266453, 0.000916421 ),
|
||||
"times": PoolRealArray( 0, 0.1 )
|
||||
}
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=7]
|
||||
[sub_resource type="Animation" id=6]
|
||||
length = 0.3
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:translation")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.3 ),
|
||||
"transitions": PoolRealArray( 0.965936, 0.870551 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0.15, 0 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath(".:rotation_degrees")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = false
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 0.05, 0.15, 0.3 ),
|
||||
"transitions": PoolRealArray( 0.392292, 0.392292, 1, 0.329877 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ), Vector3( 0, 0, 9.73853 ), Vector3( 0, 0, 0 ) ]
|
||||
}
|
||||
tracks/2/type = "bezier"
|
||||
tracks/2/path = NodePath(".:rotation_degrees:z")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"points": PoolRealArray( 0, -0.0279863, -0.888281, 0.0279863, 0.888281, -6.53051, -0.0617135, -2.00939, 0.0466494, 1.5189, 0, -0.173703, -0.837245, 0.134235, 0.64701 ),
|
||||
"times": PoolRealArray( 0, 0.112663, 0.3 )
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=7]
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:rotation_degrees")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.3 ),
|
||||
"transitions": PoolRealArray( 0.466516, 2.37841 ),
|
||||
"update": 0,
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, -90, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="PlaneMesh" id=8]
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=9]
|
||||
flags_unshaded = true
|
||||
albedo_texture = ExtResource( 4 )
|
||||
uv1_scale = Vector3( 0.9, 0.9, 1 )
|
||||
|
@ -148,17 +157,17 @@ mesh = ExtResource( 2 )
|
|||
material/0 = ExtResource( 3 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Border"]
|
||||
anims/blur = SubResource( 8 )
|
||||
anims/drop = SubResource( 9 )
|
||||
anims/flip = SubResource( 2 )
|
||||
anims/focus = SubResource( 3 )
|
||||
anims/lift = SubResource( 4 )
|
||||
anims/tap = SubResource( 5 )
|
||||
anims/blur = SubResource( 2 )
|
||||
anims/drop = SubResource( 3 )
|
||||
anims/flip = SubResource( 4 )
|
||||
anims/focus = SubResource( 5 )
|
||||
anims/lift = SubResource( 6 )
|
||||
anims/tap = SubResource( 7 )
|
||||
|
||||
[node name="CardImage" type="MeshInstance" parent="Border"]
|
||||
transform = Transform( 0.318962, 0, 0, 0, 1, 0, 0, 0, 0.450381, 0, 0.007, 0 )
|
||||
mesh = SubResource( 6 )
|
||||
material/0 = SubResource( 7 )
|
||||
mesh = SubResource( 8 )
|
||||
material/0 = SubResource( 9 )
|
||||
[connection signal="input_event" from="." to="." method="_input_event"]
|
||||
[connection signal="mouse_entered" from="." to="." method="_mouse_hover"]
|
||||
[connection signal="mouse_exited" from="." to="." method="_mouse_blur"]
|
||||
|
|
Loading…
Reference in a new issue