42 lines
1.5 KiB
GDScript
42 lines
1.5 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 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);$".."
|
||
$"..".allClickLCBSignal.emit($"..".title+"LeftRotate",$"..")
|
||
if !$"..".allowHandle :
|
||
return
|
||
if $"..".knob_state == $"..".KNOB_STATE.AUTO:
|
||
$"../LCBRotateAnimation".play("AutoToIsolate", -1, 10)
|
||
$"..".change_knob_state($"..".KNOB_STATE.ISOLATE)
|
||
elif $"..".knob_state == $"..".KNOB_STATE.CLOSE:
|
||
$"../LCBRotateAnimation".play("CloseToAuto", -1, 10)
|
||
$"..".change_knob_state($"..".KNOB_STATE.AUTO)
|
||
elif $"..".knob_state == $"..".KNOB_STATE.OPEN:
|
||
$"../LCBRotateAnimation".play("OpenToClose", -1, 10)
|
||
$"..".change_knob_state($"..".KNOB_STATE.CLOSE)
|