46 lines
1.0 KiB
GDScript3
46 lines
1.0 KiB
GDScript3
|
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;
|
||
|
print('11111333319');
|
||
|
pass # Replace with function body.
|
||
|
|
||
|
|
||
|
# 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_area_2d_mouse_entered():
|
||
|
print('1111133331');
|
||
|
pass # Replace with function body.
|
||
|
|
||
|
|
||
|
func _on_area_2d_input_event(viewport, event, shape_idx):
|
||
|
print('111111', event);
|
||
|
if event.pressed:
|
||
|
if jjtc_state == JJTC_STATE.CLOSE:
|
||
|
jjtc_state = JJTC_STATE.OPEN
|
||
|
elif jjtc_state == JJTC_STATE.OPEN:
|
||
|
jjtc_state = JJTC_STATE.CLOSE
|
||
|
pass # Replace with function body.
|