62 lines
1.7 KiB
GDScript
62 lines
1.7 KiB
GDScript
extends TextureRect
|
|
|
|
|
|
|
|
var unlockImg = preload("res://Assets/jjtc/jjtc_unlock.png");
|
|
var lockImg = preload("res://Assets/jjtc/jjtc_lock.png");
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
self.texture = lockImg;
|
|
$"../../../../Close_Click_Area".hide()
|
|
$"../../../../JJLC_Right_Rotate".hide()
|
|
$"../../../../JJLC_Left_Rotate".hide()
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta):
|
|
pass
|
|
|
|
## 状态枚举
|
|
enum JJTC_STATE{
|
|
OPEN,# 开门
|
|
CLOSE,# 关门
|
|
}
|
|
|
|
@onready var jjtc_state : JJTC_STATE = JJTC_STATE.CLOSE :
|
|
set(value):
|
|
jjtc_state = value
|
|
if jjtc_state==JJTC_STATE.OPEN:
|
|
self.texture = unlockImg;
|
|
elif jjtc_state==JJTC_STATE.CLOSE:
|
|
self.texture = lockImg;
|
|
|
|
|
|
func _on_texture_rect_gui_input(event):
|
|
if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT && jjtc_state == JJTC_STATE.CLOSE:
|
|
jjtc_state = JJTC_STATE.OPEN
|
|
$"../../../../TextureRect".hide()
|
|
$"../../../../JJLC_Right_Rotate".hide()
|
|
$"../../../../JJLC_Left_Rotate".hide()
|
|
$"../../../../Close_Click_Area".show()
|
|
|
|
func test_close_enter():
|
|
var mouse_position = get_global_mouse_position()
|
|
return true
|
|
|
|
|
|
func _on_close_click_area_mouse_entered():
|
|
$"../../../../Close_Click_Area".set_default_cursor_shape(Control.CursorShape.CURSOR_POINTING_HAND)
|
|
|
|
|
|
func _on_close_click_area_mouse_exited():
|
|
set_default_cursor_shape(Control.CursorShape.CURSOR_ARROW)
|
|
|
|
|
|
func _on_close_click_area_gui_input(event):
|
|
if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT && jjtc_state == JJTC_STATE.OPEN:
|
|
jjtc_state = JJTC_STATE.CLOSE
|
|
$"../../../../TextureRect".show()
|
|
$"../../../../JJLC_Right_Rotate".show()
|
|
$"../../../../JJLC_Left_Rotate".show()
|
|
$"../../../../Close_Click_Area".hide()
|