diff --git a/UI/JJTC/JJTC_Left_Rotate.gd b/UI/JJTC/JJTC_Left_Rotate.gd new file mode 100644 index 0000000..3cf3098 --- /dev/null +++ b/UI/JJTC/JJTC_Left_Rotate.gd @@ -0,0 +1,32 @@ +extends Sprite2D + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + +func test_enter(): + var mouse_position = get_global_mouse_position() + return self.get_rect().has_point(to_local(mouse_position)) + +func _input(event): + if event is InputEventMouseMotion: + var flag1 = test_enter() + if flag1: + self.modulate = Color(0, 1, 1, 1) + else: + self.modulate = Color(1, 1, 1, 1) + # 鼠标在移动,可以在这里检查鼠标是否进入了当前节点的区域 + if event is InputEventMouseButton and event.pressed: + # 如果鼠标在Sprite2D上点击,则处理事件 + var flag2 = test_enter() + if flag2 and event.button_index == MOUSE_BUTTON_LEFT: + # 处理点击事件 + $"../JJTC_Right_Rotate".hide() + self.hide() + $"../JJTC_Key".hide() + $"..".pullOutKey() diff --git a/UI/JJTC/JJTC_Right_Rotate.gd b/UI/JJTC/JJTC_Right_Rotate.gd new file mode 100644 index 0000000..9fbed0e --- /dev/null +++ b/UI/JJTC/JJTC_Right_Rotate.gd @@ -0,0 +1,37 @@ +extends Sprite2D + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + +func test_enter(): + var mouse_position = get_global_mouse_position() + return self.get_rect().has_point(to_local(mouse_position)) + +func _input(event): + if event is InputEventMouseMotion: + var flag1 = test_enter() + if flag1: + self.modulate = Color(0, 1, 1, 1) + else: + self.modulate = Color(1, 1, 1, 1) + # 鼠标在移动,可以在这里检查鼠标是否进入了当前节点的区域 + if event is InputEventMouseButton and event.pressed: + # 如果鼠标在Sprite2D上点击,则处理事件 + var flag2 = test_enter() + if flag2 and event.button_index == MOUSE_BUTTON_LEFT: + # 处理点击事件 + #self.modulate = Color(0, 1, 1, 1);$".." + print("Sprite2D clicked!") + $"../PanelContainer/VBoxContainer/MarginContainer/JJTC_Box".jjtc_state = $"../PanelContainer/VBoxContainer/MarginContainer/JJTC_Box".JJTC_STATE.OPEN + $"../JJTC_Box_Voice".play() + $"../JJTC_Key".hide() + self.hide() + $"../JJTC_Left_Rotate".hide() + $"../Close_Click_Area".show() + $"../JJTC_Button".show() diff --git a/UI/JJTC/jjlc.gd b/UI/JJTC/jjlc.gd index a5d73e6..7b81b0f 100644 --- a/UI/JJTC/jjlc.gd +++ b/UI/JJTC/jjlc.gd @@ -21,7 +21,8 @@ func shouJJTCKey(): func _on_jjtc_button_gui_input(event): - print('jjtc button 按下') + if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT: + print('jjtc button 按下') func _on_jjtc_button_mouse_entered(): @@ -30,3 +31,6 @@ func _on_jjtc_button_mouse_entered(): func _on_jjtc_button_mouse_exited(): $PanelContainer/VBoxContainer/MarginContainer/JJTC_Box.set_default_cursor_shape(Control.CursorShape.CURSOR_ARROW) + +func pullOutKey(): + $"../stationKeys".showKeyAfterRemoveKey('JJTC_Key') diff --git a/UI/JJTC/jjlc.tscn b/UI/JJTC/jjlc.tscn index a0ebc41..a5e536e 100644 --- a/UI/JJTC/jjlc.tscn +++ b/UI/JJTC/jjlc.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://gjmtus0cnppi"] +[gd_scene load_steps=11 format=3 uid="uid://gjmtus0cnppi"] [ext_resource type="Script" path="res://sceen/platform/JJTC_Box.gd" id="1_sa7p7"] [ext_resource type="Script" path="res://UI/JJTC/jjlc.gd" id="1_ymor0"] @@ -8,6 +8,8 @@ [ext_resource type="Texture2D" uid="uid://350x85ekm0vo" path="res://Assets/jjtc/jjtc_button.png" id="3_t5xss"] [ext_resource type="Texture2D" uid="uid://b7j3msd4bw0im" path="res://Assets/LCB_Arrow.svg" id="4_xrw3n"] [ext_resource type="AudioStream" uid="uid://c0j0dmes382ax" path="res://Assets/music/JJTC_Box_Voice.mp3" id="7_khtfn"] +[ext_resource type="Script" path="res://UI/JJTC/JJTC_Right_Rotate.gd" id="8_3qs6d"] +[ext_resource type="Script" path="res://UI/JJTC/JJTC_Left_Rotate.gd" id="9_c03t7"] [node name="jjtc" type="Window"] position = Vector2i(0, 36) @@ -66,6 +68,7 @@ position = Vector2(224, 210) rotation = 0.912807 scale = Vector2(0.25, 0.25) texture = ExtResource("4_xrw3n") +script = ExtResource("8_3qs6d") [node name="JJTC_Left_Rotate" type="Sprite2D" parent="."] position = Vector2(132, 210) @@ -73,6 +76,7 @@ rotation = -0.912807 scale = Vector2(0.25, 0.25) texture = ExtResource("4_xrw3n") flip_h = true +script = ExtResource("9_c03t7") [node name="JJTC_Box_Voice" type="AudioStreamPlayer" parent="."] stream = ExtResource("7_khtfn") @@ -86,6 +90,3 @@ stream = ExtResource("7_khtfn") [connection signal="gui_input" from="StationKeys" to="." method="_on_station_keys_gui_input"] [connection signal="mouse_entered" from="StationKeys" to="PanelContainer/VBoxContainer/MarginContainer/JJTC_Box" method="_on_station_keys_mouse_entered"] [connection signal="mouse_exited" from="StationKeys" to="PanelContainer/VBoxContainer/MarginContainer/JJTC_Box" method="_on_station_keys_mouse_exited"] -[connection signal="gui_input" from="JJTC_Key" to="PanelContainer/VBoxContainer/MarginContainer/JJTC_Box" method="_on_texture_rect_gui_input"] -[connection signal="mouse_entered" from="JJTC_Key" to="PanelContainer/VBoxContainer/MarginContainer/JJTC_Box" method="_on_texture_rect_mouse_entered"] -[connection signal="mouse_exited" from="JJTC_Key" to="PanelContainer/VBoxContainer/MarginContainer/JJTC_Box" method="_on_texture_rect_mouse_exited"] diff --git a/UI/station_keys/station_keys_window.tscn b/UI/station_keys/station_keys_window.tscn index 1471594..b642d0b 100644 --- a/UI/station_keys/station_keys_window.tscn +++ b/UI/station_keys/station_keys_window.tscn @@ -7,7 +7,7 @@ [ext_resource type="PackedScene" uid="uid://bsr40ogx2e2ir" path="res://UI/station_keys/jjtc_key_control.tscn" id="2_cndsv"] [ext_resource type="FontFile" uid="uid://bkbpyidjguavf" path="res://Assets/FeiHuaSongTi-2.ttf" id="2_mlqh2"] [ext_resource type="PackedScene" uid="uid://biwdpy5pifxgi" path="res://UI/station_keys/lcb_key_control.tscn" id="2_xelwb"] -[ext_resource type="PackedScene" uid="uid://blixp06e6vnoe" path="res://UI/station_keys/hsjc_key_control.tscn" id="9_q6qly"] +[ext_resource type="PackedScene" path="res://UI/station_keys/hsjc_key_control.tscn" id="9_q6qly"] [ext_resource type="AudioStream" uid="uid://di5nwer0mdafr" path="res://Assets/music/箭头提示音.mp3" id="10_cspe3"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1w22c"] diff --git a/sceen/platform/JJTC_Box.gd b/sceen/platform/JJTC_Box.gd index 61d6d2f..5da2bd6 100644 --- a/sceen/platform/JJTC_Box.gd +++ b/sceen/platform/JJTC_Box.gd @@ -31,17 +31,6 @@ enum JJTC_STATE{ elif jjtc_state==JJTC_STATE.CLOSE: self.texture = lockImg; - -func _on_texture_rect_gui_input(event): - if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT && jjtc_state == JJTC_STATE.CLOSE: - jjtc_state = JJTC_STATE.OPEN - $"../../../../JJTC_Box_Voice".play() - $"../../../../JJTC_Key".hide() - $"../../../../JJTC_Right_Rotate".hide() - $"../../../../JJTC_Left_Rotate".hide() - $"../../../../Close_Click_Area".show() - $"../../../../JJTC_Button".show() - func test_close_enter(): var mouse_position = get_global_mouse_position() return true @@ -63,6 +52,7 @@ func _on_close_click_area_gui_input(event): $"../../../../JJTC_Right_Rotate".show() $"../../../../JJTC_Left_Rotate".show() $"../../../../Close_Click_Area".hide() + $"../../../../JJTC_Button".hide() func _on_station_keys_mouse_entered(): @@ -73,9 +63,3 @@ func _on_station_keys_mouse_exited(): set_default_cursor_shape(Control.CursorShape.CURSOR_ARROW) -func _on_texture_rect_mouse_entered(): - $"../../../../JJTC_Key".set_default_cursor_shape(Control.CursorShape.CURSOR_POINTING_HAND) - - -func _on_texture_rect_mouse_exited(): - set_default_cursor_shape(Control.CursorShape.CURSOR_ARROW)