added dragging cards and post its with mouse input

This commit is contained in:
Adrian Schmid 2023-06-29 22:19:58 +02:00 committed by betalars
parent 37eea81463
commit 47d4981d19
5 changed files with 95 additions and 34 deletions

View File

@ -50,6 +50,7 @@ var scale_tween
wiggle_intensity = 0
@export var voice_line: AudioStream = null
@export var is_dragable: bool = false
func _ready():
@ -93,3 +94,14 @@ func _on_focus_entered():
func _on_focus_exited():
print(self, "is not focused")
func _on_mouse_entered():
highlighted = true
func _on_mouse_exited():
highlighted = false
func _on_input_event(viewport, event, shape_idx):
if event is InputEventMouseMotion and Input.is_action_pressed("mouse_left") and is_dragable:
position += event.relative

View File

@ -202,3 +202,7 @@ offset_left = 100.0
offset_top = 148.0
offset_right = 140.0
offset_bottom = 188.0
[connection signal="input_event" from="." to="." method="_on_input_event"]
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=9 format=3 uid="uid://bnskiyx1sksww"]
[gd_scene load_steps=10 format=3 uid="uid://bnskiyx1sksww"]
[ext_resource type="Texture2D" uid="uid://bi3xqdknw5tpe" path="res://logic-scenes/board/board-texture/Cork002_2K_Color.png" id="1_8brxc"]
[ext_resource type="Shader" path="res://logic-scenes/board/physics-board.gdshader" id="1_ggnth"]
[ext_resource type="Script" path="res://logic-scenes/board/card-board.gd" id="3_8v4c4"]
[ext_resource type="PackedScene" uid="uid://dy5rd437h5hsw" path="res://logic-scenes/board/card.tscn" id="3_mg053"]
[ext_resource type="PackedScene" uid="uid://bvowj4l8dtceu" path="res://dev-util/board of devs.tscn" id="4_sskx2"]
[ext_resource type="PackedScene" uid="uid://vkcdj8c3ytbq" path="res://logic-scenes/board/post-it.tscn" id="5_048k0"]
[ext_resource type="Script" path="res://logic-scenes/board/bouncy-card.gd" id="6_gcxd7"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ttqei"]
@ -15,7 +16,7 @@ shader_parameter/tex = ExtResource("1_8brxc")
[sub_resource type="CircleShape2D" id="CircleShape2D_x8rl2"]
radius = 154.052
[node name="Panel" type="PanelContainer"]
[node name="board" type="PanelContainer"]
material = SubResource("ShaderMaterial_ttqei")
clip_contents = true
anchors_preset = 15
@ -25,46 +26,79 @@ grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 6
size_flags_vertical = 6
mouse_filter = 1
script = ExtResource("3_8v4c4")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="Panel" type="Panel" parent="HBoxContainer"]
[node name="dropzone" type="Panel" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
mouse_filter = 1
[node name="Control" type="Control" parent="HBoxContainer/Panel"]
anchors_preset = 0
offset_left = 305.0
offset_top = 463.0
offset_right = 305.0
offset_bottom = 463.0
[node name="card3" parent="HBoxContainer/dropzone" instance=ExtResource("3_mg053")]
z_as_relative = false
position = Vector2(371, 290)
rotation = 0.00712087
collision_layer = 2147483649
[node name="card3" parent="HBoxContainer/Panel/Control" instance=ExtResource("3_mg053")]
offset_left = 0.0
offset_top = 0.0
offset_right = 0.0
offset_bottom = 0.0
[node name="card" parent="HBoxContainer/dropzone" instance=ExtResource("3_mg053")]
position = Vector2(640, 659)
rotation = 0.0714344
scale = Vector2(1, 1)
is_dragable = true
[node name="VBoxContainer3" type="VBoxContainer" parent="HBoxContainer"]
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 8
[node name="CenterContainer" type="ScrollContainer" parent="HBoxContainer/VBoxContainer3"]
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
[node name="post-ancor" type="Panel" parent="HBoxContainer/VBoxContainer3/CenterContainer"]
custom_minimum_size = Vector2(320, 110)
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/ScrollContainer"]
layout_mode = 2
[node name="Panel" type="Panel" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
custom_minimum_size = Vector2(400, 120)
layout_mode = 2
mouse_filter = 1
[node name="post-it" parent="HBoxContainer/ScrollContainer/VBoxContainer/Panel" instance=ExtResource("5_048k0")]
z_index = 1
position = Vector2(105, 57)
is_dragable = true
[node name="Panel2" type="Panel" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
custom_minimum_size = Vector2(400, 120)
layout_mode = 2
mouse_filter = 1
[node name="post-it" parent="HBoxContainer/ScrollContainer/VBoxContainer/Panel2" instance=ExtResource("5_048k0")]
position = Vector2(105, 57)
is_dragable = true
[node name="Panel3" type="Panel" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
custom_minimum_size = Vector2(400, 120)
layout_mode = 2
mouse_filter = 1
[node name="post-it" parent="HBoxContainer/ScrollContainer/VBoxContainer/Panel3" instance=ExtResource("5_048k0")]
position = Vector2(105, 57)
is_dragable = true
[node name="Panel4" type="Panel" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
custom_minimum_size = Vector2(400, 120)
layout_mode = 2
mouse_filter = 1
[node name="post-it" parent="HBoxContainer/ScrollContainer/VBoxContainer/Panel4" instance=ExtResource("5_048k0")]
position = Vector2(105, 57)
is_dragable = true
[node name="board of devs" parent="." instance=ExtResource("4_sskx2")]
visible = false
layout_mode = 2
[node name="Node2D" type="Node2D" parent="."]
visible = false
[node name="RigidBody2D" type="Area2D" parent="Node2D"]
position = Vector2(686, 379)
@ -77,10 +111,8 @@ shape = SubResource("CircleShape2D_x8rl2")
position = Vector2(-151, -107)
[node name="card2" parent="Node2D/RigidBody2D/ancor" instance=ExtResource("3_mg053")]
offset_left = 0.0
offset_top = 0.0
offset_right = 0.0
offset_bottom = 0.0
rotation = -0.0180459
collision_layer = 2
[node name="RigidBody2D2" type="Area2D" parent="Node2D"]
position = Vector2(742, 323)
@ -93,10 +125,8 @@ shape = SubResource("CircleShape2D_x8rl2")
position = Vector2(-151, -107)
[node name="card2" parent="Node2D/RigidBody2D2/ancor" instance=ExtResource("3_mg053")]
offset_left = 0.0
offset_top = 0.0
offset_right = 0.0
offset_bottom = 0.0
rotation = 0.0612526
collision_layer = 2
[node name="RigidBody2D3" type="Area2D" parent="Node2D"]
position = Vector2(694, 353)
@ -109,7 +139,5 @@ shape = SubResource("CircleShape2D_x8rl2")
position = Vector2(-151, -107)
[node name="card2" parent="Node2D/RigidBody2D3/ancor" instance=ExtResource("3_mg053")]
offset_left = 0.0
offset_top = 0.0
offset_right = 0.0
offset_bottom = 0.0
rotation = 0.0528008
collision_layer = 2

View File

@ -41,6 +41,7 @@ var modulate_tween
modulate = Color(1, 1, 1)
@export var voice_line: AudioStream = null
@export var is_dragable: bool = false
func _ready() -> void:
$Content/Label.text = self.text
@ -60,3 +61,14 @@ func _on_focus_entered():
func _on_focus_exited():
print(self, "is not focused")
func _on_mouse_entered():
#owner.grab_highlight(self)
highlighted = true
func _on_mouse_exited():
highlighted = false
func _on_input_event(viewport, event, shape_idx):
if event is InputEventMouseMotion and Input.is_action_pressed("mouse_left") and is_dragable:
position += event.relative

View File

@ -103,6 +103,7 @@ animations = [{
[node name="post-it" type="Area2D"]
script = ExtResource("1_yvh5n")
highlight_color = Color(1.2, 1.2, 1.2, 1)
is_dragable = null
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(99.5, 0)
@ -133,3 +134,7 @@ theme = ExtResource("3_hu2as")
theme_type_variation = &"card_text"
vertical_alignment = 1
autowrap_mode = 3
[connection signal="input_event" from="." to="." method="_on_input_event"]
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]