godot-psd-training/UI/LCB/LCB_Right_Rotate.gd

43 lines
1.5 KiB
GDScript3
Raw Normal View History

2024-04-16 09:46:51 +08:00
extends Sprite2D
2024-04-15 14:54:06 +08:00
# 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
2024-04-16 09:46:51 +08:00
func test_enter():
var mouse_position = get_global_mouse_position()
return self.get_rect().has_point(to_local(mouse_position))
2024-04-15 14:54:06 +08:00
2024-04-16 09:46:51 +08:00
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+"RightRotate",$"..")
if !$"..".allowHandle :
return
2024-04-16 09:46:51 +08:00
if $"..".knob_state == $"..".KNOB_STATE.AUTO:
2024-05-11 13:34:00 +08:00
$"../LCBRotateAnimation".play("AutoToClose", -1, 10)
2024-04-16 09:46:51 +08:00
$"..".change_knob_state($"..".KNOB_STATE.CLOSE)
elif $"..".knob_state == $"..".KNOB_STATE.ISOLATE:
2024-05-11 13:34:00 +08:00
$"../LCBRotateAnimation".play("IsolateToAuto", -1, 10)
2024-04-16 09:46:51 +08:00
$"..".change_knob_state($"..".KNOB_STATE.AUTO)
elif $"..".knob_state == $"..".KNOB_STATE.CLOSE:
2024-05-11 13:34:00 +08:00
$"../LCBRotateAnimation".play("CloseToOpen", -1, 10)
2024-04-16 09:46:51 +08:00
$"..".change_knob_state($"..".KNOB_STATE.OPEN)
2024-05-15 13:44:54 +08:00
$"../AudioStreamPlayer".play()