You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
833 B

class_name Coin
extends Area2D
# Collectible that disappears when the player touches it.
onready var animation_player = $AnimationPlayer
# The Coins only detects collisions with the Player thanks to its collision mask.
# This prevents other characters such as enemies from picking up coins.
# When the player collides with a coin, the coin plays its 'picked' animation.
# The animation takes cares of making the coin disappear, but also deactivates its
# collisions and frees it from memory, saving us from writing more complex code.
# Click the AnimationPlayer node to see the animation timeline.
func _on_body_entered(_body):
global.secrets_found += 1
global.show_message("You found a secret spot! (" + global.secrets_found as String + "/" + get_parent().get_parent().SECRETS as String + ")")
animation_player.play("picked")