Flopsy/objects/door/door.gd

22 lines
500 B
GDScript

extends StaticBody2D
export var key : String = "yellow"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _on_PlayerCollision(body):
if $Sprite.frame == 0 and GlobalState.keys[key] == true:
$Sprite.play("open")
$AudioOpen.play()
print("open")
elif $Sprite.frame == 0 and GlobalState.keys[key] == false:
$AudioLocked.play()
func _on_Sprite_animation_finished():
collision_layer = 0
GlobalState.keys[key] = false