godot-psd-training/UI/JJTC/JJTC_Left_Rotate.gd

39 lines
1.1 KiB
GDScript3
Raw Normal View History

2024-04-29 11:22:44 +08:00
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):
2024-05-30 16:45:00 +08:00
if self.visible == false:
return
2024-04-29 11:22:44 +08:00
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:
# 处理点击事件
$"..".allClickJJTCSignal.emit('JJTCLeftRotate',$"..")
if !$"..".allowHandle :
return
2024-04-29 11:22:44 +08:00
$"../JJTC_Right_Rotate".hide()
self.hide()
$"../JJTC_Key".hide()
$"..".pullOutKey()
2024-05-30 16:45:00 +08:00
$"../JJTC_Button".hide()