2024-04-19 17:48:20 +08:00
|
|
|
|
extends Sprite2D
|
|
|
|
|
|
|
|
|
|
@onready var open_light: Sprite2D = $"../../Light/openLight"
|
|
|
|
|
|
|
|
|
|
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.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
|
|
|
|
# 如果鼠标在Sprite2D上点击,则处理事件
|
|
|
|
|
var flag2 = test_enter()
|
|
|
|
|
if flag2:
|
2024-05-29 15:18:03 +08:00
|
|
|
|
$"../..".clickKeySwitchSignal.emit(true,$"../..")
|
2024-05-13 15:44:09 +08:00
|
|
|
|
if !$"../..".allowHandle :
|
|
|
|
|
return
|
2024-05-29 15:18:03 +08:00
|
|
|
|
$"../Key".rotation=PI/6
|
|
|
|
|
$"../Keyhole".rotation=PI/6
|
|
|
|
|
open_light.visible = true
|
2024-05-15 13:44:54 +08:00
|
|
|
|
$"../AudioStreamPlayer".play()
|