diff options
Diffstat (limited to 'collectables/Apple.gd')
-rw-r--r-- | collectables/Apple.gd | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/collectables/Apple.gd b/collectables/Apple.gd index abf0db3..c69a100 100644 --- a/collectables/Apple.gd +++ b/collectables/Apple.gd @@ -1,13 +1,16 @@ extends Node2D export var health=10 +var collected = false func _ready(): $AnimationPlayer.play("idle") func _on_Area2D_body_entered(body): - if (body.name=="Player"): - body.health += health + if (body.name=="Player" and !collected): + collected = true + SignalBus.emit_signal("on_apples_collected",1) self.hide() + $Sprite/Area2D.set_collision_mask_bit(1,false) $pickup.play() func _on_pickup_finished(): |