43 lines
1.4 KiB
GDScript
43 lines
1.4 KiB
GDScript
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 self.visible == false:
|
||
return
|
||
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);$".."
|
||
$"..".allClickJJTCSignal.emit('JJTCRightRotate',$"..")
|
||
if !$"..".allowHandle :
|
||
return
|
||
$"../PanelContainer/VBoxContainer/MarginContainer/JJTC_Box".jjtc_state = $"../PanelContainer/VBoxContainer/MarginContainer/JJTC_Box".JJTC_STATE.OPEN
|
||
$"../JJTC_Button".show()
|
||
$"../JJTC_Box_Voice".play()
|
||
$"../JJTC_Key".hide()
|
||
self.hide()
|
||
$"../JJTC_Left_Rotate".hide()
|
||
$"../Close_Click_Area".show()
|
||
$"../JJTC_Button".show()
|