Flopsy/objects/coin/coin.gd
2022-07-17 14:24:15 +02:00

30 lines
466 B
GDScript

extends StaticBody2D
enum TYPE {
bronze,
silver,
gold
}
export(TYPE) var type = TYPE.bronze
export var value : int = 0
const COIN_DEFAULT_VALUES = [
1,
2,
5
]
func _ready():
$Sprite.animation = TYPE.keys()[type]
if value == 0:
value = COIN_DEFAULT_VALUES[type]
func _on_Player_entered(body):
if visible:
body.coin_collected(value)
$SoundCollected.play()
hide()
func _on_SoundCollected_finished():
queue_free()
get_parent().remove_child(self)