diff --git a/feedback_canvas_modulate.gd b/feedback_canvas_modulate.gd new file mode 100644 index 0000000..85f5647 --- /dev/null +++ b/feedback_canvas_modulate.gd @@ -0,0 +1,15 @@ +class_name FeedbackCanvasModulate +extends CanvasModulate + + +var is_tweening = false + +func show_hurt_feedback(): + if is_tweening: return + is_tweening = true + var default_color = color + var tween = create_tween() + tween.tween_property(self, "color", Color(1.0,0,0, .2), .1) + tween.tween_property(self, "color", default_color, .3) + tween.tween_callback(func(): is_tweening = false) + diff --git a/prototype_dark_cut.tscn b/prototype_dark_cut.tscn index 4806cdb..cbf876c 100644 --- a/prototype_dark_cut.tscn +++ b/prototype_dark_cut.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=3 uid="uid://be0rqt7sk1da0"] +[gd_scene load_steps=15 format=3 uid="uid://be0rqt7sk1da0"] [ext_resource type="Texture2D" uid="uid://bicjfwpoa3pma" path="res://test_table.png" id="1_7i8d4"] [ext_resource type="Script" path="res://prototype_dark_cut.gd" id="1_vl0qk"] @@ -8,6 +8,7 @@ [ext_resource type="Texture2D" uid="uid://gf7us6an3mhu" path="res://test_star.png" id="4_frsoy"] [ext_resource type="Script" path="res://guidelines.gd" id="6_0fd2w"] [ext_resource type="Script" path="res://guideline_point.gd" id="8_5qgyw"] +[ext_resource type="Script" path="res://feedback_canvas_modulate.gd" id="9_4ghh6"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pgu75"] bg_color = Color(0.417457, 0, 0.105249, 1) @@ -28,6 +29,7 @@ radius = 5.65684 script = ExtResource("1_vl0qk") [node name="UI" type="Control" parent="."] +unique_name_in_owner = true layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -298,6 +300,10 @@ connections = Array[NodePath]([NodePath("../TestStar_915")]) [node name="CollisionShape2D" type="CollisionShape2D" parent="Guidelines/TestStar1_916/Area2D"] shape = SubResource("CircleShape2D_0bwgd") +[node name="FeedbackCanvasModulate" type="CanvasModulate" parent="."] +unique_name_in_owner = true +script = ExtResource("9_4ghh6") + [connection signal="value_changed" from="UI/HBoxContainer/PatienceBar" to="." method="_on_patience_bar_value_changed"] [connection signal="area_entered" from="UtilsDropoff/Area2D" to="TestScalpel" method="_on_dropoff_area_entered"] [connection signal="area_exited" from="UtilsDropoff/Area2D" to="TestScalpel" method="_on_dropoff_area_exited"] diff --git a/test_scalpel.gd b/test_scalpel.gd index 3024fb0..5fc1e06 100644 --- a/test_scalpel.gd +++ b/test_scalpel.gd @@ -9,6 +9,7 @@ var is_cutting = false @onready var pickup_area = $PickupArea @onready var cut_area = $CutArea +@onready var feedback_canvas_modulate: FeedbackCanvasModulate = %FeedbackCanvasModulate func _ready(): pickup_area.connect("mouse_entered", func(): is_clickable = true) @@ -82,5 +83,6 @@ func stop_cutting(): func _on_cut_hurt_timer_timeout(): # TODO: Check if should hurt + feedback_canvas_modulate.show_hurt_feedback() %PatienceBar.value = clampi(%PatienceBar.value - 5, 0, 100) print("Splatter")