the-crypt/objects/Lever.gd

27 lines
552 B
GDScript3
Raw Normal View History

2020-07-23 11:36:28 -05:00
extends Sprite
signal on
signal off
export var lock: bool = true
var active = false
func _process(delta):
if $Area2D.get_overlapping_bodies().size() != 0:
$Label.visible = true
if Input.is_action_just_pressed("open") and not active:
emit_signal("on")
active = true
frame = 1
2020-07-23 19:47:27 -05:00
$AudioStreamPlayer2D.play(0.0)
2020-07-23 11:36:28 -05:00
elif Input.is_action_just_pressed("open") and active and not lock:
emit_signal("off")
active = false
frame = 0
2020-07-23 19:47:27 -05:00
$AudioStreamPlayer2D.play(0.0)
$AudioStreamPlayer2D.play(0.0)
2020-07-23 11:36:28 -05:00
else:
$Label.visible = false