18 lines
487 B
GDScript
18 lines
487 B
GDScript
extends Node2D
|
|
class_name PlantSprite
|
|
|
|
signal harvest_animation_finished
|
|
|
|
@onready var sprite = $Sprite2D
|
|
|
|
func apply_texture_to_sprite(texture, with_animation = true):
|
|
if with_animation:
|
|
$AnimationPlayer.play("bump")
|
|
await $AnimationPlayer.animation_finished
|
|
sprite.texture = texture
|
|
sprite.flip_h = true if randi()%2 == 0 else false
|
|
|
|
func start_harvest_animation():
|
|
$AnimationPlayer.play("harvest")
|
|
await $AnimationPlayer.animation_finished
|
|
harvest_animation_finished.emit() |