giraffe/scripts/Tree.gd

19 lines
488 B
GDScript
Raw Permalink Normal View History

extends KinematicBody2D
signal death
signal eaten
onready var speed = 1
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
set_physics_process(true)
func _physics_process(delta):
var col = self.move_and_collide(Vector2(0,speed))
if col != null and col.local_shape == $Leaves:
$Sprite.frame = 1
emit_signal("eaten")
$Leaves.disabled = true
elif col != null and col.local_shape == $Trunk:
emit_signal("death")