godot-psd-training/UI/JJTC/JJTC_Right_Rotate.gd
2024-05-30 16:45:00 +08:00

43 lines
1.4 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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()