added more sounds and autocollect coin
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
extends RigidBody2D
|
||||
@onready var animated_sprite_2d = $AnimatedSprite2D
|
||||
@export var hit_object:PackedScene
|
||||
@export var auto_collect:bool
|
||||
|
||||
var destroyed = false
|
||||
var instance = null
|
||||
var _body = null
|
||||
@onready var timer = $Timer
|
||||
|
||||
func _ready():
|
||||
animated_sprite_2d.play("idle")#
|
||||
|
||||
func _on_activate_body_entered(body):
|
||||
_body = body
|
||||
if destroyed:
|
||||
return
|
||||
|
||||
|
||||
destroyed = true
|
||||
animated_sprite_2d.play("destroy")
|
||||
@@ -17,6 +23,11 @@ func _on_activate_body_entered(body):
|
||||
if hit_object == null:
|
||||
return
|
||||
|
||||
var instance = hit_object.instantiate()
|
||||
instance = hit_object.instantiate()
|
||||
add_child(instance)
|
||||
instance.position.y -= 16
|
||||
timer.start()
|
||||
|
||||
func _on_timer_timeout():
|
||||
if auto_collect:
|
||||
instance.collect_coin(_body)
|
||||
|
||||
Reference in New Issue
Block a user