Flopsy/objects/key/key.gd

24 lines
483 B
GDScript3
Raw Normal View History

2022-07-18 12:58:38 +02:00
extends StaticBody2D
2022-07-19 22:22:16 +02:00
enum KEY_COLOR{
yellow,
red,
green,
blue
}
2022-07-20 04:28:30 +02:00
export(KEY_COLOR) var key_color = 0
2022-07-19 22:22:16 +02:00
2022-07-18 12:58:38 +02:00
func _ready():
2022-07-19 22:22:16 +02:00
$Sprite.texture = load("res://objects/key/assets/" + str(KEY_COLOR.keys()[key_color]) + ".svg")
2022-07-18 12:58:38 +02:00
$Sprite/AnimationPlayer.play("default")
func _on_PlayerCollision(body):
if visible:
2022-07-19 22:22:16 +02:00
GlobalState.keys[str(KEY_COLOR.keys()[key_color])] = true
2022-07-18 12:58:38 +02:00
$SoundCollected.play()
hide()
func _on_SoundCollected_finished():
queue_free()
get_parent().remove_child(self)