24 lines
648 B
GDScript
24 lines
648 B
GDScript
extends RigidBody2D
|
|
|
|
@onready var animated_sprite_2d = $AnimatedSprite2D
|
|
@onready var animation_player = $AnimationPlayer
|
|
@export var hit_object : PackedScene
|
|
@export var auto_collect : bool
|
|
const ITEMBLOCK = preload("res://scenes/blocks/itemblock.tscn")
|
|
|
|
func _ready():
|
|
animated_sprite_2d.play("default")
|
|
|
|
func _on_activate_body_entered(body):
|
|
if hit_object == null:
|
|
if body.is_big:
|
|
animation_player.play("destroy")
|
|
else:
|
|
var inst2 = ITEMBLOCK.instantiate()
|
|
get_parent().add_child(inst2)
|
|
inst2.position.x = position.x
|
|
inst2.position.y = position.y
|
|
inst2.hit_object = hit_object
|
|
inst2.auto_collect = auto_collect
|
|
queue_free()
|